Wildfly 9.0.2 设置 https 侦听器

Wildfly 9.0.2 setting https listener

我已经为此苦苦挣扎了 2 天。我想在本地 Mac 上的 Wildfly 9.0.2.Final 上设置 https 侦听器。我是野蝇的新手。我已经从我的生产环境中复制了我的 wildfly 设置(domain.xml 和 host.xml),但是在 Prod 上,我们有负载均衡器来路由到 https 流量,我不想在我的本地设置负载均衡器。我已经在互联网上查找并得到了这么远: 1. 按照 link 生成自签名证书: https://docs.jboss.org/author/pages/viewpage.action?pageId=66322705&_sscc=t 2. 在host.xml:

中添加了一个安全域
<security-realm name="SSLRealm">
  <server-identities>
    <ssl>
      <keystore path="foo.keystore" relative-to="jboss.domain.config.dir" alias="foo" keystore-password="secret" key-password="secret" />
    </ssl>
  </server-identities>
</security-realm>
  1. 在 domain.xml 我有几个配置文件设置,每个配置文件都有一个子系统。从我的在线搜索中,我了解到我需要在 undertow 子系统中添加一个 https-listener。现在,我不太清楚我在哪个 undertow 子系统中添加了 https 侦听器。我仍然将它添加到部署我的应用程序的配置文件中(因为我只希望本地的一个应用程序使用 https 侦听器)。我的domain.xml部分在问题的最后。

我的应用程序通过 http 的端口是 8580(我已将端口偏移量设置为 500),即,我在 URL 上访问我的应用程序: http://localhost:8580/myApp 当我去任何一个: https://localhost/ or https://localhost:8580 or https://localhost:443 or https://localhost/myApp 我刚收到 "This site can't be reached. localhost refused to connect." 回复。 作为 Wildfly 的新手,我不知道我在哪里犯了错误,也不知道访问 HTTPS URL 的端口应该是什么。 如果我需要提供更多信息,请告诉我。 任何帮助将不胜感激。

<profiles>
                            <profile name="content-profile">
                                   <subsystem.......
                                   <subsystem xmlns="urn:jboss:domain:undertow:2.0">
                                    <buffer-cache name="default"/>
                                    <server name="default-server">
                                        <ajp-listener name="ajp" socket-binding="ajp"/>
                                        <http-listener name="default2" socket-binding="http" redirect-socket="https" proxy-address-forwarding="true" max-post-size="10737418240" max-parameters="5000"/>
                                        <https-listener name="default" 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>
                                    <servlet-container name="default">
                                        <jsp-config/>
                                        <websockets/>
                                    </servlet-container>
                                    <handlers>
                                        <file name="welcome-content" path="${jboss.home.dir}/welcome-content"/>
                                    </handlers>
                                    <filters>
                                        <response-header name="server-header" header-name="Server" header-value="WildFly/9"/>
                                        <response-header name="x-powered-by-header" header-name="X-Powered-By" header-value="Undertow/1"/>
                                    </filters>
                                </subsystem>
                          </profile>
                    </profiles>

好的。我只是弄明白了,所以想发布答案来帮助可能面临同样问题的人。 我已经正确设置了一切(<ssl> 在 host.xml 中的 <server-identites> 和 undertow 子系统中的 <https-listener> 下。我只是不知道访问 https 连接的端口号。盯着我的 domain.xml 一段时间后,我注意到 <socket-binding-groups> 标签,它看起来像这样:

<socket-binding-groups>
        <socket-binding-group name="standard-sockets" default-interface="public">
            <socket-binding name="ajp" port="${jboss.ajp.port:8009}"/>
            <socket-binding name="http" port="${jboss.http.port:8080}"/>
            <socket-binding name="https" port="${jboss.https.port:8443}"/>
            <socket-binding name="txn-recovery-environment" port="4712"/>
            <socket-binding name="txn-status-manager" port="4713"/>
            <outbound-socket-binding name="mail-smtp">
                <remote-destination host="localhost" port="25"/>
            </outbound-socket-binding>
        </socket-binding-group>
 ....

安全连接的端口号是 8443,我为我的应用程序设置了 500 作为端口偏移量,所以当我访问 https://localhost:8943/myApp 时......瞧!我收到接受证书的提示,接受后,我会看到主页。 :D