【发布时间】:2014-10-03 10:54:24
【问题描述】:
是否可以在同一个独立 Wildfly 上运行 SSL 和非 SSL Web 应用程序?
我正在使用 Wildfly 8.1.0 (Undertow),但在配置此场景时遇到了麻烦... 例如,我知道如何自己配置 HTTP 或 HTTPS,但是每当我尝试为两者运行配置时,HTTP 响应都会重定向到 SSL 的... :(
有人可以指出要更改的内容,例如在默认的standalone.xml 中吗?
【问题讨论】:
是否可以在同一个独立 Wildfly 上运行 SSL 和非 SSL Web 应用程序?
我正在使用 Wildfly 8.1.0 (Undertow),但在配置此场景时遇到了麻烦... 例如,我知道如何自己配置 HTTP 或 HTTPS,但是每当我尝试为两者运行配置时,HTTP 响应都会重定向到 SSL 的... :(
有人可以指出要更改的内容,例如在默认的standalone.xml 中吗?
【问题讨论】:
是的,这是可能的。
首先你需要在 ApplicationRealm 中添加如下代码
<server-identities>
<ssl>
<keystore path="server.keystore" relative-to="jboss.server.config.dir" keystore-password="abcd1234" alias="server" key-password="abcd1234"/>
</ssl>
</server-identities>
那么你需要为 http 和 https 添加 lisner
<server name="default-server">
<http-listener name="default-http" socket-binding="http"/>
<https-listener name="default-https" socket-binding="https" security-realm="ApplicationRealm"/>
<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>
现在为 http 和 https 配置连接器
<subsystem xmlns="urn:jboss:domain:remoting:2.0">
<endpoint worker="default"/>
<http-connector name="http-remoting-connector" connector-ref="default-http" security-realm="ApplicationRealm"/>
<http-connector name="https-remoting-connector" connector-ref="default-https" security-realm="ApplicationRealm"/>
</subsystem>
但通常人们不会同时启用 http 和 https。他们将请求从 http 重定向到 https。
【讨论】: