1. 描述
问题: 浏览器打开https://www.aa.com/aaa.html,然后跳转到http://www.aa.com/aaa.html
网站架构:用户–https—> nginx代理 —http—→ tomcat/nginx+php
nginx待遇发给后端的请求是http协议,后端程序跳转获取到的协议是http,返回一个redirect(http header中带Location:http://www.aa.com/aaa.html),浏览器收到location,跳转到了location指定的地方。
2. 解决方法
2.1. 解决方法1
在nginx代理中增加一个header,标志用户请求是http还是https,后端获取header决定跳转到http/https页面。这个方法需要修改nginx配置和程序,不推荐,但是可以解决问题。
2.2. 解决方法2
nginx代理中配置proxy_redirect
proxy_redirect http:// $scheme://;
示例:
location /hi{ proxy_pass http://10.10.10.10:8080/hi; proxy_set_header Host $http_host; proxy_set_header X-Forward-For $remote_addr; proxy_redirect http:// $scheme://; }
以上指令会将后端响应header location内容中的http:替换成用户端协议https:。 NGINX访问https跳转到http的解决了~
原文连接:https://blog.csdn.net/leonnew/article/details/86510011
文章评论