简体   繁体   English

使用自动 SSL 证书在 AWS Elastic Beanstalk 上部署 Spring Boot 应用程序

[英]Deploy Spring Boot application on AWS Elastic Beanstalk with automatic SSL certificates

Let's say I have a Spring Boot project that produces a JAR file www.example.com.jar which using its embedded HTTP server shows a example page showing the word "Example".假设我有一个 Spring 启动项目,该项目生成一个 JAR 文件www.example.com.jar ,它使用其嵌入式 HTTP 服务器显示一个示例页面,显示单词“Example”。

  • I want to deploy this bare JAR file on AWS Elastic Beanstalk.我想在 AWS Elastic Beanstalk 上部署这个裸文件 JAR。
  • I want SSL/TLS support for my custom domain, ie https://www.example.com/ .我希望我的自定义域支持 SSL/TLS,即https://www.example.com/
  • I want to use Amazon's own Amazon Certificate Manager.我想使用亚马逊自己的 Amazon Certificate Manager。
  • I want Amazon Certificate Manager to automatically renew the certificate as needed.我希望 Amazon Certificate Manager 根据需要自动续订证书。
  • I am happy to use Amazon's Route 53 if necessary for DNS.如有必要,我很乐意为 DNS 使用亚马逊的 Route 53。
  • I am willing to use load balancer(s) if necessary.如有必要,我愿意使用负载均衡器。
  • I am willing to use Amazon's CloudFront if necessary.如有必要,我愿意使用亚马逊的 CloudFront。
  • I do not want a solution that makes me manually renew a certificate and copy it somewhere from time to time.我不想要一个让我手动更新证书并不时将其复制到某个地方的解决方案。
  • I do not want a solution that requires me to create an EC2 instance;我不想要一个需要我创建 EC2 实例的解决方案; I want to deploy a bare JAR.我想部署一个裸机 JAR。

What are the options to meet all these requirements?满足所有这些要求的选项是什么? (Most of the tutorials I've seen skip the SSL part altogether, even though SSL is mandatory on today's web). (我看到的大多数教程都完全跳过了 SSL 部分,尽管 SSL 在今天的网络上是强制性的)。

Lastly if this is simply not possible with a bare JAR file, but would be possible with a bare Docker image, I would be interested in meeting these same requirements using a bare Docker image.最后,如果这对于裸 JAR 文件根本不可能,但对于裸 Docker 图像是可能的,我有兴趣使用裸 Docker 图像来满足这些相同的要求。

  • I want to deploy this bare JAR file on AWS Elastic Beanstalk.我想在 AWS Elastic Beanstalk 上部署这个裸文件 JAR。

  • I do not want a solution that requires me to create an EC2 instance;我不想要一个需要我创建 EC2 实例的解决方案; I want to deploy a bare JAR.我想部署一个裸机 JAR。

These two statements don't make sense to me.这两个陈述对我来说没有意义。 You want to use Elastic Beanstalk, but you don't want to use EC2 instances?您想要使用 Elastic Beanstalk,但又不想使用 EC2 实例? Elastic Beanstalk is nothing more than a service that manages EC2 instances for you. Elastic Beanstalk 只不过是一项为您管理 EC2 实例的服务。 When you deploy your application with Elastic Beanstalk it is going to create one or more EC2 instances and deploy your application on those.当您使用 Elastic Beanstalk 部署您的应用程序时,它将创建一个或多个 EC2 实例并将您的应用程序部署在这些实例上。

To deploy your Spring Boot application to Elastic Beanstalk, follow this official guide .要将 Spring Boot 应用程序部署到 Elastic Beanstalk,请遵循此官方指南

To meet your SSL requirements, you need to create an SSL certificate in AWS ACM for the domain you own ( www.example.com ), and pick DNS validation.为了满足您的 SSL 要求,您需要在 AWS ACM 中为您拥有的域 ( www.example.com ) 创建一个 SSL 证书,并选择 DNS 验证。 Then create the DNS record it tells you to, to validate your ownership of the domain.然后创建它告诉您的 DNS 记录,以验证您对该域的所有权。

Next, deploy your Java application to Elastic Beanstalk with a load balancer.接下来,使用负载均衡器将您的 Java 应用程序部署到 Elastic Beanstalk。 Then attach the AWS ACM certificate to the load balancer.然后将 AWS ACM 证书附加到负载均衡器。 Finally, create a DNS CNAME record for www.example.com that points to the DNS name of the load balancer.最后,为www.example.com创建一条 DNS CNAME 记录,指向负载均衡器的 DNS 名称。 You don't need to use Route53 for this unless you are trying to point a root domain ( example.com instead of www.example.com ) to your load balancer.您不需要为此使用 Route53,除非您尝试将根域( example.com而不是www.example.com )指向您的负载均衡器。

Might have stumbled through to satisfaction of all of these requirements except for potentially the automatic renewal / re-installation of the certificate:除了可能自动更新/重新安装证书之外,可能已经偶然满足了所有这些要求:

  • yes, bare Spring Boot JAR file on AWS Elastic Beanstalk.是的,裸 Spring 在 AWS Elastic Beanstalk 上启动 JAR 文件。
  • yes, SSL/TLS support for my custom domain, ie https://www.example.com/ .是的,我的自定义域支持 SSL/TLS,即https://www.example.com/
  • yes, did use Amazon's own Amazon Certificate Manager.是的,确实使用了亚马逊自己的 Amazon Certificate Manager。
  • I don't know, but I'm hopeful that Amazon Certificate Manager will automatically renew the certificate as needed.我不知道,但我希望 Amazon Certificate Manager 会根据需要自动续订证书。
  • yes, Amazon's Route 53 is something I'm using for DNS.是的,亚马逊的 Route 53 是我用于 DNS 的东西。
  • yes, I broke down and became willing to use load balancer(s) and used one是的,我崩溃了,开始愿意使用负载均衡器并使用了一个
  • I don't know about CloudFront yet.我还不知道 CloudFront。
  • didn't have to set up an EC2 instance directly不必直接设置 EC2 实例

One of the most difficult parts was arranging for the redirection of HTTP traffic to HTTPS. The documentation was leading me to an.ebextensions config solution -- but that seemed problematic because it seemed to be setting up a chicken-and-egg problem for testing the configuration.最困难的部分之一是安排将 HTTP 流量重定向到 HTTPS。文档引导我找到 .ebextensions 配置解决方案——但这似乎有问题,因为它似乎正在为测试设置一个先有鸡还是先有蛋的问题配置。 I felt relieved when I found some documentation about how to configure load balancer rules that actually led me to functionality I needed to set up the redirection in the load balancer itself: https://docs.aws.amazon.com/elasticloadbalancing/latest/application/listener-update-rules.html#edit-rule当我找到一些关于如何配置负载均衡器规则的文档时,我感到如释重负,这些文档实际上引导我实现了在负载均衡器本身中设置重定向所需的功能: https://docs.aws.amazon.com/elasticloadbalancing/latest/应用程序/listener-update-rules.html#edit-rule

Prior to redirecting to HTTPS, I had to set up HTTPS on the load balancer.在重定向到 HTTPS 之前,我必须在负载均衡器上设置 HTTPS。 The doc I used for that was https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/configuring-https-elb.html我为此使用的文档是https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/configuring-https-elb.html

To get the public certificate set up for my custom domain, I used ACM: https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request-public.html为了为我的自定义域设置公共证书,我使用了 ACM: https://docs.aws.amazon.com/acm/latest/userguide/gs-acm-request-public.html

And originally, I got going with a hosted zone for my custom domain with Route 53. And I had to go to my domain registrar, godaddy, to set up the DNS entries to utilize Route 53. Once DNS was pointed to the AWS Hosted Zone DNS hosts, I didn't really have to go back to godaddy any more.最初,我使用 Route 53 为我的自定义域设置了一个托管区域。我必须向我的域注册商 godaddy 发送 go,以设置 DNS 条目以使用 Route 53。一旦 DNS 指向 AWS 托管区域DNS 主机,我真的不必再将 go 返回给 godaddy。

I'm about 4 or 5 days into this effort, so my head is still spinning a bit.我已经进行了大约 4 或 5 天的努力,所以我的头还在旋转。 The directions I followed to get the application launched initially were the ones at https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-platform.html .我最初启动应用程序所遵循的说明是https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/java-se-platform.html中的说明。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 无法在 AWS Elastic Beanstalk 中部署 Spring 引导应用程序 - Unable to Deploy Spring Boot Application in AWS Elastic Beanstalk 在使用 RDS 的 AWS (Elastic Beanstalk) 上部署 Spring 引导应用程序 - 应用程序未启动 - Deploy Spring Boot application on AWS (Elastic Beanstalk) that uses RDS - Application does not start 我可以使用 AWS Elastic Beanstalk 托管 Spring Boot 应用程序吗 - Can I use AWS Elastic Beanstalk to host a Spring Boot application 如何在 Tomcat AWS Elastic beanstalk (Spring Boot Application) 中修改或添加新的 Nginx 配置 - How to modify or add new Nginx configuration in Tomcat AWS Elastic beanstalk (Spring Boot Application) 将 django 部署到 AWS Elastic Beanstalk - deploy django to AWS Elastic Beanstalk 如何使用 github 操作部署到 aws elastic beanstalk? - How to deploy to aws elastic beanstalk with github actions? 如何在要部署到 AWS 弹性豆茎中的 Flask 应用程序中使用我的 firebase 凭证? - How can I use my firebase credentials in a Flask application that I want to deploy in a AWS elastic beanstalk? Github 动作将 django 应用程序部署到弹性 beanstalk - Github actions deploy django application to elastic beanstalk 如何将 LetsEncrypt SSL 安装到运行 Tomcat 8 和 Java 8 平台的 AWS Elastic Beanstalk 应用程序上 - How do I install LetsEncrypt SSL onto AWS Elastic Beanstalk application running Tomcat 8 with Java 8 Platform 如何配置 AWS CodePipeline、CodeBuild 和 Elastic Beanstalk 以正确部署 Laravel 8 应用程序? - How do I configure AWS CodePipeline, CodeBuild, and Elastic Beanstalk to deploy a Laravel 8 application correctly?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM