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。

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

4

2 回答 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"

这个设置在 Apache 后面的 Tomcat 或 Wildfly 对我来说效果很好。

于 2016-06-08T17:03:27.720 回答
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
于 2018-03-13T07:07:22.343 回答