本文主要是介绍Structs2 Reponse rediret 使用https,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!
问题:
Structs2 action中的redirect只支持Http,当应用部署在Https环境下时。会报错:
Mixed Content: The page at ‘https://managertest.efun.com/userlogin.mainWindow.shtml’ was loaded over HTTPS, but requested an insecure script ‘http://manager.efun.com/js/upload.js’. This request has been blocked; the content must be served over HTTPS.
<action name="serviceManagerAction_*" class="serviceManagerAction" method="{1}"><result name="listPage">/serviceList.jsp</result><result name="updateUI">/serviceList.jsp</result><result name="update" type="redirect">serviceManagerAction_search.shtml?searchGame=${gid}&beginTime=${beginTime}&endTime=${endTime}&area=${area}&gameCode=${gameCode}</result><result name="delete" type="redirect">serviceManagerAction_search.shtml?searchGame=${gid}&beginTime=${beginTime}&endTime=${endTime}&area=${area}</result><result name="save" type="redirect">serviceManagerAction_search.shtml?searchGame=${gid}&beginTime=${beginTime}&endTime=${endTime}&area=${area}&gameCode=${gameCode}</result>
</action>
解决过程
- 查询解决方案,可以使用struts2-ssl-plugin插件,使用说明
于是按照文档部署,测试时发现服务器不断重定向请求,问题处理失败。日志如下:
[2017-01-16 17:09:34.326] {http-192.168.10.39:8040-1$1934196892} Going to SSL mode, redirecting to https://managertest.efun.com:443/userlogin.mainWindow.shtml
- 之后发现服务器中使用https是通过ngnix根据域名的规则将所有请求转为https的。重定向的问题可能和这个有关。但是具体原因不清楚。 既然是通过ngnix来转https的。那么考虑也通过Ngnix将应用的Response的redirect也转换为Htpps来解决问题
解决方案参考
How do I rewrite URLs in a proxy response in NGINX
个人博客: Vioao’s Blog
这篇关于Structs2 Reponse rediret 使用https的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!