NGINX访问https跳转到http的解决方法

管理员 NginxNGINX访问https跳转到http的解决方法已关闭评论69,9583字数 510阅读1分42秒阅读模式

问题:浏览器打开https://www.ttlsa.com/aaa.html,然后跳转到https://www.ttlsa.com/aaa.html

网站架构:用户--https--->nginx代理---http---->tomcat/nginx+php文章源自运维生存时间-https://www.ttlsa.com/nginx/resolve-https-rewrite-to-http/

nginx待遇发给后端的请求是http协议,后端程序跳转获取到的协议是http,返回一个redirect(http header中带Location:https://www.ttlsa.com/aaa.html),浏览器收到location,跳转到了location指定的地方。文章源自运维生存时间-https://www.ttlsa.com/nginx/resolve-https-rewrite-to-http/

解决方法

解决方法1:文章源自运维生存时间-https://www.ttlsa.com/nginx/resolve-https-rewrite-to-http/

在nginx代理中增加一个header,标志用户请求是http还是https,后端获取header决定跳转到http/https页面。这个方法需要修改nginx配置和程序,不推荐,但是可以解决问题。文章源自运维生存时间-https://www.ttlsa.com/nginx/resolve-https-rewrite-to-http/

解决方法2文章源自运维生存时间-https://www.ttlsa.com/nginx/resolve-https-rewrite-to-http/

nginx代理中配置proxy_redirect文章源自运维生存时间-https://www.ttlsa.com/nginx/resolve-https-rewrite-to-http/

proxy_redirect http:// $scheme://;

以上指令会将后端响应header location内容中的http://替换成用户端协议https://。文章源自运维生存时间-https://www.ttlsa.com/nginx/resolve-https-rewrite-to-http/

NGINX访问https跳转到http的解决了~文章源自运维生存时间-https://www.ttlsa.com/nginx/resolve-https-rewrite-to-http/

 文章源自运维生存时间-https://www.ttlsa.com/nginx/resolve-https-rewrite-to-http/ 文章源自运维生存时间-https://www.ttlsa.com/nginx/resolve-https-rewrite-to-http/

weinxin
我的微信
微信公众号
扫一扫关注运维生存时间公众号,获取最新技术文章~
管理员
  • 本文由 发表于 05/06/2017 01:00:27
  • 转载请务必保留本文链接:https://www.ttlsa.com/nginx/resolve-https-rewrite-to-http/