我正在尝试使http-> https与弹性beantalk一起使用,并且它们的文档似乎不起作用。我已将负载均衡器设置为成功终止http和https。
http://example.com
https://example.com
都是工作。
This documentation说明了如何将https配置为http重定向。我在Spring Boot中使用java-se,所以我已经读过the readme并将.ebextensions
放在我的src/main/resources
文件夹中。
因此,我完成的spring boot jar具有myapp.jar/BOOT-INF/classes/.ebextensions/nginx/conf.d/elasticbeanstalk/00_application.conf
,其中包括:
location / {
set $redirect 0;
if ($http_x_forwarded_proto != "https") {
set $redirect 1;
}
if ($http_user_agent ~* "ELB-HealthChecker") {
set $redirect 0;
}
if ($redirect = 1) {
return 301 https://$host$request_uri;
}
proxy_pass http://127.0.0.1:5000;
proxy_http_version 1.1;
proxy_set_header Connection $connection_upgrade;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
在里面。但是没有任何内容重定向到https。
答案 0 :(得分:1)
好,知道了!将.ebextensions
放在项目的根文件夹中,而不要放在src/main/resources
的根文件夹中。然后添加bootJar
命令以将该文件夹粘贴在完成的jar的顶层,AWS需要将其放置在该文件夹中:
compileKotlin {
kotlinOptions {
freeCompilerArgs = ["-Xjsr305=strict"]
jvmTarget = "1.8"
}
bootJar {
from('.ebextensions') {
into('.ebextensions' )
}
}
}
感谢您对这个问题的回答,让我了解到了其余的解决方法:
How do you build a folder into the .jar root of a spring boot gradle project?