首页 > 解决方案 > 如何使用 asadmin 启动脚本将 Let's Encrypt 密钥/证书添加到 Payara Micro

问题描述

我使用 certbot 独立服务器成功为我的设置生成了 Let's Encrypt 证书,但现在我想将它们移动到 payara 微型容器中进行生产。Payara Micro 允许我将 asadmin 命令放入它获取并运行的 pre/post 脚本中。

首先,这里是创建容器的 docker 命令:

docker run -p 8765:8090 \
           --mount type=bind,src=$(pwd)/deployments,dst=/opt/payara/deployments \
           --mount type=bind,src=$(pwd)/lib,dst=/opt/payara/lib \
           --mount type=bind,src=$(pwd)/cert,dst=/opt/payara/cert \
           --mount type=bind,src=$(pwd)/scripts,dst=/opt/payara/scripts \
           --env-file payara.env \
           --restart=always \
           payara/micro:5.191 \
           --prebootcommandfile /opt/payara/scripts/preboot.asadmin \
           --addlibs /opt/payara/lib \
           --deploy /opt/payara/deployments/MyApp.war \
           --sslport 8090 \
           --sslcert le_myapp \
           --contextroot ROOT

preboot.asadmin脚本有一行:

add-pkcs8 --domain_name production --destalias "le_myapp" --priv-key-path /opt/payara/cert/privkey.pem --cert-chain-path /etc/letsencrypt/opt/payara/cert/fullchain.pem

当然,注册证书失败,并且日志没有提供任何关于失败原因的有用信息:

[2019-05-29T16:41:48.329+0000] [] [WARNING] [] [fish.payara.boot.runtime.BootCommand] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1559148108329] [levelValue: 900] Boot Command add-pkcs8 failed Exception while executing command. 

[2019-05-29T16:41:48.999+0000] [] [INFO] [] [fish.payara.boot.runtime.BootCommand] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1559148108999] [levelValue: 800] [[
  Boot Command set returned with result SUCCESS : PlainTextActionReporterSUCCESSDescription: set AdminCommandnull
    configs.config.server-config.network-config.network-listeners.network-listener.https-listener.port=8090
]]

[2019-05-29T16:41:49.042+0000] [] [INFO] [] [fish.payara.boot.runtime.BootCommand] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1559148109042] [levelValue: 800] [[
  Boot Command set returned with result SUCCESS : PlainTextActionReporterSUCCESSDescription: set AdminCommandnull
    configs.config.server-config.network-config.network-listeners.network-listener.https-listener.enabled=true
]]

[2019-05-29T16:41:49.114+0000] [] [INFO] [] [fish.payara.boot.runtime.BootCommand] [tid: _ThreadID=1 _ThreadName=main] [timeMillis: 1559148109114] [levelValue: 800] [[
  Boot Command set returned with result SUCCESS : PlainTextActionReporterSUCCESSDescription: set AdminCommandnull
    configs.config.server-config.network-config.protocols.protocol.https-listener.ssl.cert-nickname=le_myapp
]]

更新 1:

我向payara/Payara/issues/4010提交了一个问题,因为我认为这是 Micro 版命令的问题。如果该问题有更新,我将在此处发布更新。

更新 2:

正如 github 问题上所建议的那样,我--domain_name production从命令中删除了。我什至尝试了非微型payara/server-web:5.192. 都没有奏效。在本机安装上应用相同的 asadmin 命令就可以了。

标签: dockerpayarapayara-micro

解决方案


推荐阅读