配置 Https 阻止 http wildfly 8.2(即不在 web.xml 中使用安全约束)

Configure Https blocking http wildfly 8.2 (i.e without using security-constraint in web.xml)

迁移Jboss6到WildFly8.2

正在处理 wildlfy8.2 中的 https keystone 连接。使用 http://blog.eisele.net/2015/01/ssl-with-wildfly-8-and-undertow.html 在独立 full.xml conf 上配置我的应用程序后。我能够在我的应用程序上访问 http 和 https 我必须单独访问 https 阻止 http。在 web.xml 中添加 security-constraint 后,我能够重定向到 https。但我不想在我的新版本中包含 web.xml 中的任何内容,它会影响我的老 jboss 用户。

在某些情况下,有些人在使用 jboss6 应用程序时未配置 SSL 密钥库,而有些人在 Https 中使用相同的应用程序。 jboss 的旧版本允许在 server.xml 本身中配置 http 和 https。在 Wildfly 中,我们必须编辑应用程序 war 文件而不是服务器配置文件。

注意:我得到了这个 link,同样的问题在 https://developer.jboss.org/thread/253008?_sscc=t 中得到了解决。按照指示进行更改。但它不起作用,我们使用的是 standalone-full.xml 而不是 standalone.xml.

进行更改后,我收到网络服务端口错误:

jboss.deployment.subunit."XXX.ear"."XXXEJB3.jar".INSTALL: JBAS018733: Failed to process phase INSTALL of subdeployment "XXXEJB3.jar" of deployment "XXX.ear"
at org.jboss.as.server.deployment.DeploymentUnitPhaseService.start(DeploymentUnitPhaseService.java:166) [wildfly-server-8.2.0.Final.jar:8.2.0.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.startService(ServiceControllerImpl.java:1948) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at org.jboss.msc.service.ServiceControllerImpl$StartTask.run(ServiceControllerImpl.java:1881) [jboss-msc-1.2.2.Final.jar:1.2.2.Final]
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [rt.jar:1.8.0_31]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [rt.jar:1.8.0_31]
at java.lang.Thread.run(Thread.java:745) [rt.jar:1.8.0_31]
Caused by: java.lang.IllegalStateException: JBAS017350: Could not find the port number listening for protocol HTTP/1.1
at org.wildfly.extension.undertow.WebServerService.getPort(WebServerService.java:67)
at org.jboss.as.webservices.config.WebServerInfoImpl.getPort(WebServerInfoImpl.java:36)

对于 Http bloacking 和 Https 启用,请更改独立-full.xml(即对于自定义服务器)或 standalone.xml,如下所示

1: 在消息传递中 - hornetq-server 子系统连接器将 http 更改为 https

<http-connector name="http-connector" socket-binding="https">
<http-connector name="http-connector-throughput" socket-binding="https">

2: undertow子系统改变

   <http-listener name="default" socket-binding="http"/>

<https-listener name="default-ssl" socket-binding="https" security-realm="UndertowRealm"/> 

注意: https-listener name default-ssl 在消息子系统 http-acceptor 和 remoting 子系统 http-connector 中使用此名称

3: 给messaging-hornetq-server子系统http-acceptor和remoting子系统http-connector的connector-ref作为https-listener名称

<subsystem xmlns="urn:jboss:domain:messaging:2.0">....
<http-acceptor http-listener="default-ssl" name="http-acceptor"/>
<http-acceptor http-listener="default-ssl" name="http-acceptor-throughput">...</subsystem>

<subsystem xmlns="urn:jboss:domain:remoting:2.0">....
<http-connector name="http-remoting-connector" connector-ref="default-ssl" security-realm="ApplicationRealm"/>....</subsystem>

对于错误:将 modify-wsdl-address 添加到 true 并将 wsdl-port 添加到 80 比 https 阻止 http.

<subsystem xmlns="urn:jboss:domain:webservices:1.2">
        <modify-wsdl-address>true</modify-wsdl-address>
        <wsdl-host>${jboss.bind.address:127.0.0.1}</wsdl-host>
        <wsdl-port>80</wsdl-port>
        <endpoint-config name="Standard-Endpoint-Config"/>
        <endpoint-config name="Recording-Endpoint-Config">
            <pre-handler-chain name="recording-handlers" protocol-bindings="##SOAP11_HTTP ##SOAP11_HTTP_MTOM ##SOAP12_HTTP ##SOAP12_HTTP_MTOM">
                <handler name="RecordingHandler" class="org.jboss.ws.common.invocation.RecordingServerHandler"/>
            </pre-handler-chain>
        </endpoint-config>
        <client-config name="Standard-Client-Config"/>
    </subsystem>