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}&amp;beginTime=${beginTime}&amp;endTime=${endTime}&amp;area=${area}&amp;gameCode=${gameCode}
    </result>
    <result name="delete" type="redirect">
        serviceManagerAction_search.shtml?searchGame=${gid}&amp;beginTime=${beginTime}&amp;endTime=${endTime}&amp;area=${area}
    </result>
    <result name="save" type="redirect">
        serviceManagerAction_search.shtml?searchGame=${gid}&amp;beginTime=${beginTime}&amp;endTime=${endTime}&amp;area=${area}&amp;gameCode=${gameCode}
    </result>
</action>

解决过程

  1. 查询解决方案,可以使用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

  1. 之后发现服务器中使用https是通过ngnix根据域名的规则将所有请求转为https的。重定向的问题可能和这个有关。但是具体原因不清楚。 既然是通过ngnix来转https的。那么考虑也通过Ngnix将应用的Response的redirect也转换为Htpps来解决问题

解决方案参考

How do I rewrite URLs in a proxy response in NGINX


个人博客: Vioao’s Blog

发布了37 篇原创文章 · 获赞 58 · 访问量 16万+
展开阅读全文

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览