[英]AWS Elastic Beanstalk (single instance) : how to enable HTTPS for a Spring Boot application?
I recently started exploring AWS and have successfully deployed a Spring Boot application on a single Elastic Beanstalk instance.我最近开始探索 AWS,并在单个 Elastic Beanstalk 实例上成功部署了 Spring Boot 应用程序。 As a next step, I'd like to have my application use HTTPS.作为下一步,我想让我的应用程序使用 HTTPS。 Given that my app is packaged as a jar, I strictly followed this official documentation: Terminating HTTPS on EC2 instances running Java SE .鉴于我的应用程序被打包为 jar,我严格遵循此官方文档: 在运行 Java SE 的 EC2 实例上终止 HTTPS 。
But my app still works with HTTP only.但我的应用程序仍然仅适用于 HTTP。 Did anybody managed to do so?有没有人设法做到这一点? Any help or link to a working example would be appreciated.任何帮助或指向工作示例的链接将不胜感激。
Some technical details about my app: it's a Maven-based Spring Boot project.关于我的应用程序的一些技术细节:它是一个基于 Maven 的 Spring 引导项目。 As explained in the doc, I've created the +.ebextensions+ folder with all the config files at the root of my project.正如文档中所解释的,我在项目的根目录下创建了包含所有配置文件的 +.ebextensions+ 文件夹。 I then used maven-antrun-plugin to include the.ebextensions folder in the jar file.然后我使用 maven-antrun-plugin 将 .ebextensions 文件夹包含在 jar 文件中。
Thanks in advance for your answers.提前感谢您的回答。
Its likely that you are using current version of EB, which is for Amazon Linux 2 (AL2);您可能正在使用当前版本的 EB,它适用于Amazon Linux 2 (AL2); not stated in the question what is used.问题中没有说明使用的是什么。 The tutorial you've linked uses old version of the EB, which is for Amazon Linux 1 (AL1).您链接的教程使用旧版本的 EB,它适用于Amazon Linux 1 (AL1)。
Subsequently, it will not work.随后,它将无法正常工作。 Specifically, the nginx
settings from the tutorial ( .ebextensions/nginx/conf.d/
and .ebextensions/nginx/conf.d/https.conf
) will be ignored .具体来说,教程中的nginx
设置( .ebextensions/nginx/conf.d/
和.ebextensions/nginx/conf.d/https.conf
)将被忽略。 The reason is that for AL2, the nginx
settings should be provided using .platform/nginx/conf.d
and .platform/nginx/nginx.conf
.原因是对于 AL2,应使用.platform/nginx/conf.d
和.platform/nginx/nginx.conf
提供nginx
设置。
Also please be aware that there are many differences between AL1 and AL2 in EB, and more changes may be required in the tutorial to make it work on AL2:另请注意,EB 中的 AL1 和 AL2 之间存在许多差异,教程中可能需要进行更多更改才能使其在 AL2 上工作:
Since its not explicitly stated in your question, which version of EB are you using, if this is indeed AL2, you could try running your app using old version of AL1.由于在您的问题中没有明确说明您使用的是哪个版本的 EB,如果这确实是 AL2,您可以尝试使用旧版本的 AL1 运行您的应用程序。 This at least would enable you to confirm that it actually works.这至少可以让您确认它确实有效。 Then you could think of how to port it to AL2.然后你可以考虑如何将它移植到 AL2。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.