Nginx 反向代理过程中出现 https 访问 http 问题

  |   0 评论   |   0 浏览

  一般对于浏览器来说 https 的网站 中访问 http 是 如下有问题的

1Mixed Content: The page at 'https://www.xxx.com/' was loaded over HTTPS, 
2but requested an insecure script 'http://www.xxx.com/a.js'.
3 This request has been blocked; the content must be served over HTTPS.

  修改 nginx 的 proxy 配置部分,如下所示

1add_header Content-Security-Policy upgrade-insecure-requests;
2proxy_set_header Host $host;
3proxy_set_header X-Real-IP $remote_addr;
4proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

  重启 nginx,这个时候我们会发现,问题解决了

---------------------------------------------------------------
>> 博客地址:https://blog.mufengs.com
>> 邮箱地址:[email protected]
>> 微信帐号:Do8080
>> Github : https://github.com/mufengcoding
---------------------------------------------------------------