nginx配置https

nginx配置https

https需要的证书我们已经申请到了,下面分享下nginx配置https的一些配置参数!

这是我的配置


========================================================================

server {

listen 443 ssl;

    ssl on;

    ssl_certificate /etc/letsencrypt/live/zhanj163.com/fullchain.pem;

    ssl_certificate_key /etc/letsencrypt/live/zhanj163.com/privkey.pem;

    server_name  go.zhanj163.com;

    root /alidata/www/go_workspace/src/go_zhanj163;

    index index.html index.htm;

    location ~ .*\.(gif|jpg|jpeg|png|bmp|swf) {

            expires      30d;

    }

    location ~ .*\.(js|css)? {

            expires      12h;

    }

    location /(css|js|fonts|img)/ {

        access_log off;

        expires 1d;

        root "/alidata/www/go_workspace/src/go_zhanj163";

        try_files $uri @backend;

    }

    location / {

        try_files /_not_exists_ @backend;

    }

    location @backend {

        proxy_pass_header Server;

        proxy_set_header X-Forwarded-For $remote_addr;

        proxy_set_header Host            $http_host;

        proxy_redirect off;

        proxy_pass http://127.0.0.1:8080;

    } 

    access_log  /alidata/log/nginx/access/go.zhanj163.com;

}

===================================================================


如果想启用https同时也想启用http,我们可以这样配置


配置文件基本不用怎么修改!


nginx强制使用https

为了数据安全,我们可以设置强制使用https!


我配置的相对简单,不影响使用,就是一个指向配置!

https://www.linuxidc.com/Linux/2017-12/149764.htm


https://github.com/certbot/certbot

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容