【发布时间】:2021-01-03 15:50:58
【问题描述】:
我正在使用没有负载均衡器的 AWS Elastic-beanstalk 作为我的 Java Spring Boot 应用程序的服务器。我想添加 SSL 证书文件并更新 nginx 配置以在我的 Web 应用上接受 SSL 流量。
我不希望使用负载平衡器,因为我不想产生额外的每月费用。
我目前的部署过程是在使用以下命令创建 JAR 文件后:
`mvn 清洁包' 我从 AWS 控制台上传 jar 文件。
使用 AWS documentation,我们可以使用以下语法添加自定义文件:
files:
/etc/pki/tls/certs/server.crt:
content: |
-----BEGIN CERTIFICATE-----
certificate file contents
-----END CERTIFICATE-----
/etc/pki/tls/certs/server.key:
content: |
-----BEGIN RSA PRIVATE KEY-----
private key contents # See note below.
-----END RSA PRIVATE KEY-----
container_commands:
01restart_nginx:
command: "service nginx restart"
并更新 NGINX 配置,在以下路径中添加更新的配置:
ebextensions/nginx/conf.d/https.conf
但是,我的证书文件和 Nginx 配置没有更新。
到目前为止我所做的尝试:
点击此链接:
Spring Boot + Elastic Beanstalk .ebextensions in JAR
它会更新 EC2 实例中的证书文件,但不会更新 NGINX,并且部署也会失败并出现以下错误。
Application deployment failed at 2020-09-16T08:43:16Z with exit status 1 and error: Engine execution has encountered an error.
Incorrect application version "system-backend-source-28" (deployment 33). Expected version "system-backend-source-27" (deployment 32).
我使用的是 Amazon Linux 2 因此,我没有将配置文件放在 .ebextension 文件夹中,而是遵循了这个答案并将 NGINX 配置文件放在 .platform 目录中,但部署通过但不更新新的 NGINX 配置。它也不上传证书文件。
How to extend nginx config in elastic beanstalk (Amazon Linux 2)
如果我手动编辑 Nginx 配置并更新证书文件,我的实例使用 HTTPS 成功运行。但正如人们所看到的,这仍然是手动的,实际上这样做消除了使用 Elastic beanstalk 的目的。有没有办法在部署时自动上传证书文件并更新 NGINX 配置?
【问题讨论】:
-
使用 Certbot 指令对您有帮助吗? certbot.eff.org
标签: amazon-web-services spring-boot ssl nginx amazon-elastic-beanstalk