https 连接子域 URL 更改

发布于 2024-12-11 06:11:30 字数 535 浏览 0 评论 0原文

https 连接子域

我希望使用 HTTPS 设置我的 wickets 1.5 应用程序。

我已将以下内容添加到我的应用程序类中。

setRootRequestMapper(new HttpsMapper(getRootRequestMapper(), new HttpsConfig(8080, 8443)));
mountPage("/go/securepage", securePage.class);

正如我用 "@RequireHttps" 注释 securePage.class 一样,链接正确地使用 HTTPS 加载页面。

但是我想将所有 https 连接转发到一个单独的子域。

不会转到 https://www.example.com/go/securepage,而是

因此,用户 被转发到 https://securepage.example.com/go/securepage

如何做到这一点?

Https Connection subdomain

Im Looking to set up my wickets 1.5 application with HTTPS.

I have added the following to my Application Class.

setRootRequestMapper(new HttpsMapper(getRootRequestMapper(), new HttpsConfig(8080, 8443)));
mountPage("/go/securepage", securePage.class);

As i have annotated the securePage.class with "@RequireHttps" the Link correctly loads the page with HTTPS.

However i want to forward all https connections to a seperate subdomain.

So instead of going to

https://www.example.com/go/securepage the user is forwarded to
https://securepage.example.com/go/securepage

How can this be done?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

命硬 2024-12-18 06:11:30

我从来不需要这样做,但查看 HttpsMapper 看来我们可以通过覆盖 HttpsMapper.mapHandler()

public Url mapHandler(IRequestHandler requestHandler) {
        Url url = delegate.mapHandler(requestHandler);
        switch (checker.getProtocol(requestHandler)){
            case HTTP :
                url.setProtocol("http");
                url.setPort(httpsConfig.getHttpPort());
                break;
            case HTTPS :
                url.setProtocol("https");
                url.setPort(httpsConfig.getHttpsPort());
                break;
        }
        return url;
    }

因此,您可以像这样覆盖它:

setRootRequestMapper(new HttpsMapper(getRootRequestMapper(), new HttpsConfig(8080, 8443)){
    @Override
    public Url mapHandler(IRequestHandler requestHandler) {
        Url url = super.mapHandler(requestHandler);
        if ("https".equals(url.getProtocol)){
            // Force the HostName for HTTPS requests
            url.setHost("securepage.example.com");   
        }
        return url;
    }
});

I've never needed to do this, but looking at the sources of HttpsMapper it seems you will we able to do this by overriding HttpsMapper.mapHandler().

public Url mapHandler(IRequestHandler requestHandler) {
        Url url = delegate.mapHandler(requestHandler);
        switch (checker.getProtocol(requestHandler)){
            case HTTP :
                url.setProtocol("http");
                url.setPort(httpsConfig.getHttpPort());
                break;
            case HTTPS :
                url.setProtocol("https");
                url.setPort(httpsConfig.getHttpsPort());
                break;
        }
        return url;
    }

So, you can override it like this:

setRootRequestMapper(new HttpsMapper(getRootRequestMapper(), new HttpsConfig(8080, 8443)){
    @Override
    public Url mapHandler(IRequestHandler requestHandler) {
        Url url = super.mapHandler(requestHandler);
        if ("https".equals(url.getProtocol)){
            // Force the HostName for HTTPS requests
            url.setHost("securepage.example.com");   
        }
        return url;
    }
});
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文