前几天用nginx 代理https后,应用redirect https变成http,导致网站无法访问的问题,在网上找了半天,终于找到了解决方法了。
虽然自己解决了,我相信还有其他朋友遇到过这个问题,所以转载分享一下:
原因分析:
浏览器到nginx是https,nginx到应用服务器变成http,
应用服务器,再做302 redirect的时候,返回的redirect 地址就好变成http的地址;
原因是spring mvc的servlet的secheme取值,request.getScheme()
是取请求里的一个scheme值,所有这个值在nginx代理时要设置成https
其中: request.getScheme() return http but not https.
解决方法:
改成这样
<code></code><pre class="brush:php;toolbar:false;" code_snippet_id="1720247" snippet_file_name="blog_20160617_1_8702952" name="code">server {
listen 80 default_server;
location / {
proxy_pass http://127.0.0.1:8080;
proxy_redirect http:// $scheme://;
}
}以上就介绍了 nginx 代理https后,spring mvc web应用redirect https变成http,包括了方面的内容,希望对PHP教程有兴趣的朋友有所帮助。
每个人都需要一台速度更快、更稳定的 PC。随着时间的推移,垃圾文件、旧注册表数据和不必要的后台进程会占用资源并降低性能。幸运的是,许多工具可以让 Windows 保持平稳运行。
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号