首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Nginx未升级到Https

Nginx未升级到Https
EN

Stack Overflow用户
提问于 2020-06-09 17:06:19
回答 1查看 182关注 0票数 2

我已经将nginx配置为将请求升级为https

代码语言:javascript
复制
server {
        listen xxx.xxx.xxx.xxx:80;
        listen xxx.xxx.xxx.xxx:443 ssl;

        server_name example.com www.example.com

        access_log  /var/log/nginx/www.example.com_access.log;
        error_log /var/log/nginx/www.example.com_error.log warn;

        ssl_certificate /etc/nginx/ssl/certificates/www.example.com.crt;
        ssl_certificate_key  /etc/nginx/ssl/certificates/www.example.com.key;

    location / {
        proxy_set_header  Host $host;
        proxy_set_header  X-Real-IP $remote_addr;
        proxy_set_header  X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header  X-Forwarded-Proto $scheme;
        #https://www.scalescale.com/tips/nginx/504-gateway-time-out-using-nginx/
        proxy_connect_timeout       600;
        proxy_send_timeout          600;
        proxy_read_timeout          600;
        send_timeout                600;
        proxy_pass https://xxx.xxx.xxx.xxx:8443/;
        index  index.html ;
    }
}

但是配置没有将请求升级到https。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-06-09 19:34:58

代码语言:javascript
复制
server {
    listen       80;
    server_name  example.com www.example.com;
    return       301 https://$host$request_uri;
}

server {
    listen       443 ssl;
    server_name  example.com www.example.com;
    ...
}

如果你不需要加密后端和nginx实例之间的流量(如果它们在同一台服务器上工作,你肯定不需要加密),可以在proxy_pass指令中删除https协议,以获得一些性能优势。

票数 5
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/62278887

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档