使用 https 时 Wicket 不正确的可收藏页面 url
Wicket incorrect bookmarkable page url when using https
我有两个页面:
- PageA.html
- PageB.html
PageA 包含一个 link 到 PageB,指定为:
add(new BookmarkablePageLink<Void>("link", PageB.class, parameters));
只要 PageB 只是一个普通的 http 页面,它就可以正常工作。页面A上的link url显示为“http://www.example.com/PageB”。
当我将 PageB 更改为需要 https 时出现问题,如下所示:
@RequireHttps
public class PageB extends WebPage {
...
}
现在PageA上的linkurl突然用本地ip代替域名了,这样“https://127.0.0.1/PageB”。这意味着我网站上的访问者无法访问 PageB,因为 url 不正确。
PageB使用“@RequireHttps”怎么会在url中使用本地ip?
我希望 url 像以前一样使用域名,只是将协议从 http 更改为 https。
我是 运行 我在 Tomcat 7 Nginx 下的 webapp。
Http Mapper 使用HttpServletRequest#getServerName()
创建绝对URL,你必须调整server.xml
中<host>
元素的名称。
我的问题现已解决。我在这里找到了答案:
基本上,我像这样更新了我的 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"/>
希望对遇到同样问题的其他人有所帮助。
我有两个页面:
- PageA.html
- PageB.html
PageA 包含一个 link 到 PageB,指定为:
add(new BookmarkablePageLink<Void>("link", PageB.class, parameters));
只要 PageB 只是一个普通的 http 页面,它就可以正常工作。页面A上的link url显示为“http://www.example.com/PageB”。
当我将 PageB 更改为需要 https 时出现问题,如下所示:
@RequireHttps
public class PageB extends WebPage {
...
}
现在PageA上的linkurl突然用本地ip代替域名了,这样“https://127.0.0.1/PageB”。这意味着我网站上的访问者无法访问 PageB,因为 url 不正确。
PageB使用“@RequireHttps”怎么会在url中使用本地ip? 我希望 url 像以前一样使用域名,只是将协议从 http 更改为 https。
我是 运行 我在 Tomcat 7 Nginx 下的 webapp。
Http Mapper 使用HttpServletRequest#getServerName()
创建绝对URL,你必须调整server.xml
中<host>
元素的名称。
我的问题现已解决。我在这里找到了答案:
基本上,我像这样更新了我的 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"/>
希望对遇到同样问题的其他人有所帮助。