【发布时间】:2016-05-06 19:19:16
【问题描述】:
我在 tomcat 8 前面有带 ssl 的 nginx,而 moqui 在 tomcat 里面。
moqui conf文件中的webapp部分是
<webapp name="webroot" http-port="" https-enabled="false">
<root-screen host=".*" location="component://webroot/screen/webroot.xml"/>
</webapp>
ssl 标头的 nginx conf
proxy_set_header Accept-Encoding "";
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $http_host;
proxy_set_header X-Forwarded-Host $host;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_pass http://localhost:8080/;
proxy_http_version 1.1;
Tomcat 添加 RemoteIpValve
<Valve className="org.apache.catalina.valves.RemoteIpValve"
internalProxies="192\.168\.1\.14|127\.0\.0\.1"
remoteIpHeader="x-forwarded-for"
remoteIpProxiesHeader="x-forwarded-by"
protocolHeader="x-forwarded-proto"
/>
这应该适用于 tomcat (moqui) 为所有资源提供 https:// 地址。
但我在地址上发现了一种奇怪的模式。每 3 次刷新一个页面(例如登录),我得到一次 https:// 地址,另外两次得到 http://。如果我刷新页面非常快,那么模式就会改变,使用 http:// 一到两次,然后使用 https:// 一次。当它是https://页面并且页面上的链接也是https时,点击页面上的链接时会转到http。
我使用 moqui 1.6.2 运行 nginx 1.8.0 和 tomcat 8。不知道有没有人也遇到这个问题。而且我不知道是 nginx 和 tomcat 的问题,还是 moqui 的问题。非常感谢任何想法。
【问题讨论】: