首页 文章

WildFly多个域和SSL证书

提问于
浏览
6

我有两个不同的域名

  • example1.com

  • example2.com

每个域都有自己的SSL证书 .

我现在要做的是,为同一个WildFly实例使用两个域,支持SSL .

WildFly文档指出,我只能引用密钥库中的单个证书 . 因此,我不能只用一个包含两个证书的密钥库来定义单个 <security-realm> .

因此,我定义了两个不同的 <security-realm> . 每个域一个 .

<security-realm name="RealmExample1">
                <server-identities>
                    <ssl>
                        <keystore path="example1.jks" keystore-password="secret" />
                    </ssl>
                </server-identities>
                ...
            </security-realm>

  <security-realm name="RealmExample2">
                <server-identities>
                    <ssl>
                        <keystore path="example2.jks" keystore-password="secret2" />
                    </ssl>
                </server-identities>
                ...
            </security-realm>

但是,我无法将两个安全域添加到单个主机 .

<server name="default-server">
                <http-listener name="default" socket-binding="http" redirect-socket="https-ext"/>
                <https-listener name="default-ssl" security-realm="UndertowRealm" socket-binding="https"/>
                <host name="default-host" alias="localhost">
                    <filter-ref name="central-basic-auth"/>
                </host>
            </server>

现在,如果我为每个域定义一个服务器,我就无法引用相同的http / https侦听器绑定,因为端口被阻止了 .

到目前为止我找到的唯一解决方案是拥有两个公共IP地址,并为每个接口定义两个接口和一个http / https套接字绑定 . 然后我能够定义两个具有不同别名和不同套接字绑定的服务器 .

截至目前,WildFly不幸不支持SNI .

还有其他可能的解决方案吗?

2 回答

  • 5

    虽然它会使您的部署有点复杂,您是否考虑过将Apache httpd放在Wildfly服务器前面?这并不困难,它确实支持SNI . 您必须更改Apache的证书,然后,使用Apache虚拟主机,您可能会有类似的东西:

    <VirtualHost _default_:443>
        ServerName www.firstdomain.com
        ProxyPreserveHost on
        ProxyPass / http://localhost:8080/
        ProxyTimeout 360
    </VirtualHost>
    

    在第一个虚拟主机文件中:

    <VirtualHost _default_:443>
        ServerName www.seconddomain.com
        ProxyPreserveHost on
        ProxyPass / http://localhost:9080/ # if it is a different instance or
        ProxyPass / http://localhost:8080/app2 # if it the same instance, different webapp
        ProxyTimeout 360
    </VirtualHost>
    

    同样,问题在于您需要维护另一个进程,并且您需要为Apache设置SSL . 但是,您可以使用Apache来执行SSL,如果您愿意,可以使用以下内容:

    Header set Content-Security-Policy ...
    Header set X-XSS-Protection "1; mode=block"
    

    这个设置对我来说非常适用于Tomcat或Apache后面的Wildfly .

  • 0

    对不起necroposting,但有一个更简单的选项 - 只需将几个域添加到一个证书 .

    通配符证书的明显方法 .

    但是,Let's Encrypt允许为一个证书指定多个域 . 它工作正常,无需等待免费的通配符证书

    sh /root/.acme.sh/acme.sh --issue -d yourdomain.com -d www.yourdomain.com -d more.yourdomain.com -w /opt/wildfly-10.1.0.Final/welcome-content
    

相关问题