我有两个页面:
- PageA.html
- PageB.html
PageA 包含指向 PageB 的链接,指定方式如下:
add(new BookmarkablePageLink<Void>("link", PageB.class, parameters));
只要 PageB 只是一个普通的 http 页面,它就可以正常工作。 PageA 上的链接 url 显示为“http://www.example.com/PageB”。
当我将 PageB 更改为需要 https 时出现问题,如下所示:
@RequireHttps
public class PageB extends WebPage {
...
}
现在,PageA 上的链接 url 突然使用本地 ip 而不是域名,这样“https://127.0.0.1/PageB”。这意味着我网站上的访问者无法访问 PageB,因为 url 不正确。
PageB使用“@RequireHttps”时,怎么会在url中使用本地ip? 我希望 url 像以前一样使用域名,并且只将协议(protocol)从 http 更改为 https。
我在 Nginx 下的 Tomcat 7 中运行我的 webapp。
最佳答案
我的问题现在已经解决了。我在这里找到了答案:https://stackoverflow.com/a/32090722/1826061
基本上,我像这样更新了我的 nginx 配置:
proxy_set_header X-Forwarded-Host $host;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
然后我将这个 Valve 添加到我的 Tomcat 配置中:
<Valve className="org.apache.catalina.valves.RemoteIpValve"
remoteIpHeader="X-Forwarded-For"
protocolHeader="X-Forwarded-Proto"
protocolHeaderHttpsValue="https"/>
希望它可以帮助其他遇到同样问题的人。
关于java - 使用 https 时 Wicket 不正确的可 Collection 页面 url,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50952783/