java - 使用 https 时 Wicket 不正确的可 Collection 页面 url

标签 java apache nginx https wicket

我有两个页面:

  • 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/

相关文章:

python - Django 与 Gunicorn 的不同部署方式

java - 如何只返回出现次数最少的字符串的ArrayList?

java - 从存储在 HashMap 中的类创建新实例

java - addMouseListener() 不适用于 JScrollPane 下的 JPanel

apache - 如何在使用 mod_proxy 的同时将用户发送到 Apache 中的另一个 "site"?

apache - 如何在 cakephp 2 中添加 header 过期

java - SSH 到 Cisco Nexus 交换机

mysql - 如何找回丢失的 phpMyAdmin 密码,XAMPP

docker - 如何自动停止docker容器?

node.js - 间歇性 502 错误网关错误(使用 nginx、nodejs、mongodb)