当前位置: 首页 > 面试题库 >

将HTTP请求重定向到Wildfly 10中的https

高锦
2023-03-14
问题内容

这是我的standalone-full.xml配置,其中ssl配置了

security realm .

      <security-realm name="SslRealm">
            <server-identities>
            <ssl>
            <keystore path="D:\ncm.keystore" alias="ncm" keystore-password="*****" />
            </ssl>
            </server-identities>
        </security-realm>

Subsystem

 <server name="default-server">
            <http-listener name="default" socket-binding="http" redirect-socket="https"/>
            <https-listener name="default-ssl" socket-binding="https" security-realm="SslRealm"/>
            <host name="default-host" alias="localhost">
                <location name="/" handler="welcome-content"/>
                <filter-ref name="server-header"/>
                <filter-ref name="x-powered-by-header"/>
            </host>
        </server>

Socket Binding

   <socket-binding name="http" port="${jboss.http.port:8080}"/>
    <socket-binding name="https" port="${jboss.https.port:8443}"/>

问题答案:

重写规则可用于重定向用户。在undertow子系统(standalone.xml或domain.xml)中,你需要创建一个新的重写过滤器,然后在新的fitler-ref中启用该过滤器:

在过滤器部分中创建新的重写过滤器。在下面的示例中,用户将被重定向到https://myhostname:443/my-app。%U是原始请求URL路径的占位符;你想使用%U使重定向友好,并保留用户的原始请求URL路径。

<filters>
<rewrite name="http-to-https" redirect="true" target="https://myhostname:8443%U"/>
</filters>

然后,启用过滤器并在主机部分中配置谓词。谓词是你在其中配置重写过滤器的html" target="_blank">对象。在下面的示例中,我们的重写筛选器将仅应用于去往端口8080的请求。

    <server name="default-server">
        <host name="default-host" alias="localhost">
            ...
            <filter-ref name="http-to-https" predicate="equals(%p,8080)"/>

以下是上述相同配置更改的JBoss CLI步骤:

/subsystem=undertow/configuration=filter/rewrite=http-to-https:add(redirect="true",target="https://myhostname:8443%U")
/subsystem=undertow/server=default-server/host=default-host/filter-ref=http-to-https:add(predicate="equals(%p,8080)")


 类似资料:
  • 我将spring saml扩展与Apache2.2+Tomcat7.0+OKTA(IdP)一起使用。securitycontext.xml如下所示: MetadataGeneratorFilter: 谢谢 奈良 HTTP请求转储:

  • 当我们使用AWS应用型负载均衡将传入请求重定向到我们的服务器时,我们创建了一个SSL证书并将其设置为负载均衡器。它同时监听HTTP 80和HTTPS 443端口的流量。在这两种情况下,流量都被重定向到目标组实例的HTTP 80端口。 在这些情况下,有nginx服务器配置为侦听它们所在的实例的HTTP 80端口。 当我更新nginx.conf文件以将传入的HTTP请求重定向到HTTPS协议时,我们面

  • 我们的整个网站将通过https提供服务。我在每条路线上都有“https”。但是,如果他们试图通过http将其重定向到https,我该如何将其重定向到https?

  • 我试图点击一个postendpoint,但它给出了错误302,当我在同一台服务器上尝试另一个get Url时,它给出了200。然后,我使用laxrirectstrategy()重定向了post请求。post请求正在重定向到get请求(只有同一个endpoint的方法名是get和post),它没有从post方法获得响应。有人能告诉我如何使用apahce httpClient 4.5将post请求重定

  • 我们使用拉维5。要将http连接重定向到https,请使用中间件HttpsProtocol。 在我们的4个测试用例中,只有1个正确工作(最后一个重定向)。其他3种情况的中间件添加了url extra index.php。 http://www.aqualink.az/index.php ---

  • 我想问一下HTTP到HTTPS的重定向。正如我们所知,重定向是通过从web服务器端重定向来实现的。但是,当涉及到https重定向时,它可以通过两种方式完成,服务器端()和应用程序端()。我想知道: 以下哪种方法有效且性能更好。 考虑到同一服务器上的多个域和域,每种方法的优缺点 非常感谢。 参考: 将Laravel中的WWW重定向到非WWW-堆栈溢出