amazon-web-services - 如何在 JBoss EAP 6.4 中将 http 重定向到 https?

标签 amazon-web-services ssl redirect jboss-eap-6

这里是如何将substitution设置为任何地址,以便我可以在 AWS Application Load Balancer 中使用它。

<subsystem xmlns="urn:jboss:domain:web:2.2" default-virtual-server="default-host" native="false">
<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http"/>
<connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https"  enable-lookups="false" secure="true" />
<virtual-server name="default-host" enable-welcome-root="true">
    <rewrite pattern="^/(.*)$" substitution="https://localhost:443/$1" flags="RL">
        <condition test="%{HTTPS}" pattern="off" />
    </rewrite>               
    <alias name="localhost"/>
    <alias name="example.com"/>
</virtual-server>

我喜欢

<rewrite pattern="^/(.*)$" substitution="https://%HOST_NAME%" flags="RL">
    <condition test="%{HTTPS}" pattern="off" />
</rewrite>

最佳答案

以下是在 EAP 6 中从 http 重定向到 https 的步骤,

redirect-port="443" 添加到 http connector 如下:

<connector name="http" protocol="HTTP/1.1" scheme="http" socket-binding="http" redirect-port="443"/>

将 https 的套接字绑定(bind)更改为 443,如下所示:

<socket-binding name="https" port="443"/>

在 EAP 6 中配置 https 连接器,

 <connector name="https" protocol="HTTP/1.1" scheme="https" socket-binding="https" secure="true">
                <ssl name="ssl" key-alias="mykey" password="password" certificate-key-file="/path/to/keystore.jks"/>
        </connector>

编辑应用程序的 web.xml 如下:-

<web-app>   
       <security-constraint>
         <web-resource-collection>
             <web-resource-name>Application</web-resource-name>
             <url-pattern>/*</url-pattern>
         </web-resource-collection>
         <user-data-constraint>
             <transport-guarantee>CONFIDENTIAL</transport-guarantee>
         </user-data-constraint>
    </security-constraint>

    </web-app>

关于amazon-web-services - 如何在 JBoss EAP 6.4 中将 http 重定向到 https?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43933730/

相关文章:

django - eb 创建 : ERROR: PermissionError - [Errno 13] Permission denied: './catroot2\\edb.log'

amazon-web-services - 如何在 Node.js 上为 dynamodb getItem 在 JSON 中表达哈希 + 范围

ssl - 是否推荐使用通配符 SSL 证书?

Python MySQLDB SSL 连接

javascript - 什么时候回发不是回发? (根据 ASP.net)

c# - 在 AWS SDK .net 中获取时间戳错误

amazon-web-services - 通过无服务器框架一次部署Lambda + API网关+ CloudFront

python - 在 Windows 上使用 Paho MQTT 库时如何指定证书颁发机构证书文件

apache - htaccess 重定向多个域,https 和 http,www 和非 www,全部重定向到一个 https 域

bash - 1>/dev/null 和 >/dev/null 和 &>/dev/null