[原创] Wildfly JBoss 如何开启 HTTPS

8 篇文章 0 订阅
本文以 WildFly 10 为例(同样适用于 8,9),说明如何为 JBoss 开启 HTTPS。

[color=red][b]系统环境说明:[/b][/color]
OS: Ubuntu 16.04 LTS 64位
Wilfdly 版本: 10.1.0

[color=red][b]其它说明:[/b][/color]
示例中的 HTTPS 证书,来自 Let's Encrypt。
申请方法,详见我的另一篇文章:“[原创] Let's Encrypt 免费开启 HTTPS 之旅”。文章地址如下:[url]http://yhz61010.iteye.com/blog/2365312[/url]

[color=red][b]前提:[/b][/color]
[list]
[*]需要通过 Let's Encrypt 申请到可用的证书文件及私钥(fullchain.pem 和 privkey.pem)。
[*]需要生成 JKS 文件。生成方法详见我的另一篇文章:“[转] Create a Java Keystore (.JKS) from Let's Encrypt Certificates”。文章地址如下:[url]http://yhz61010.iteye.com/blog/2374317[/url]
[/list][b]开启 JBoss HTTPS[/b]

将生成的 JKS 文件拷贝到 JBoss 的配置目录中:
cp keystore.jks /<jboss.home>/standalone/configuration/

编辑如下文件:
vim /<jboss.home>/standalone/configuration/standalone.xml

在 <security-realms> 节点中,插入如下配置:
<security-realm name="SslRealm">
<server-identities>
<ssl>
<keystore path="keystore.jks" relative-to="jboss.server.config.dir" keystore-password="<your password>" alias="<your alias name>" key-password="<your password>"/>
</ssl>
</server-identities>
</security-realm>

之后,找到 <subsystem xmlns="urn:jboss:domain:undertow:x.x"> 节点,并修改其中的 <server> 节点的内容(先注释掉原有的 HTTPS 配置,再追加新的配置):
<!--<https-listener name="https" socket-binding="https" security-realm="ApplicationRealm" enable-http2="true"/>-->
<https-listener name="default-ssl" socket-binding="https" security-realm="SslRealm"/>
[color=red][b]Tips:[/b][/color]从 Wildfly 8 开始,Web subsystem 已经被 Undertow subsystem 替代了。

最后重新启动 JBoss 即可:
/<jboss.home>/bin/jboss-cli.sh --connect --controller=localhost:9990 command=:shutdown
/<jboss.home>/bin/standalone.sh &

[b]参考文献:[/b]
[list]
[*][url]http://reallifejava.com/configuring-ssl-in-wildfly-8/[/url]
[*][url]https://www.youtube.com/watch?v=IcVKA0vaFkc[/url]
[/list]
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值