我使用 Elastic Beanstalk CLI 将我的 Spring Boot 应用程序部署到 EB。只要我不配置 HTTPS,它就可以正常工作。
根据用户文档,我需要做的就是在我的 .ebextensions 文件夹中创建一个 .config 文件,其中包含以下内容
option_settings:
aws:elb:listener:443:
SSLCertificateId: <arn for cert>
ListenerProtocol: HTTPS
InstancePort: 5000
InstanceProtocol: HTTP
aws:elb:listener:80:
ListenerEnabled: false
但是,如果我使用该配置创建我的环境,则由于无法与 ELB 通信,运行状况检查会失败。查看 AWS 控制台中的环境,HTTP 和 HTTPS 侦听器端口均已禁用,并且 SSL 证书未与负载均衡器关联。
鉴于行为的变化,我认为可以肯定地说 .config 文件正在被拾取和应用,即使配置在某种程度上不正确。
如果我在此阶段手动尝试通过 EB Web GUI 启用 HTTPS 侦听器,则会收到以下错误。
LoadBalancerHTTPSPort: You have specified both the @deprecated(:default.aws:elb:loadbalancer:LoadBalancerHTTPSPort) option as well as one in the new aws:elb:listener:443 namespace. The :default.aws:elb:loadbalancer:LoadBalancerHTTPSPort option will be ignored.
因此,即使我愿意,我什至无法手动启用它。
这里有很多关于上传自定义 nginx conf 文件的问题/答案。我相信这些现在已经过时并且不适用,但是如果有人可以指出我在 EB 的当前状态下可以使用的东西,我很乐意接受。
下面的一些信息供参考
我正在使用 ACM 托管我的(自签名)证书。出于我的目的,我在测试时可以使用自签名证书。我不知道这是否会使负载均衡器感到困惑,尽管文档确实提到了使用自签名证书。稍后我将转到适当的证书。
我的 .elasticbeanstalk/config.yaml 看起来像这样
branch-defaults:
default:
environment: <name>
deploy:
artifact: target/<jar name>.jar
global:
application_name: <App name>
branch: null
default_ec2_keyname: <key name>
default_platform: Java 8
default_region: eu-west-1
include_git_submodules: true
instance_profile: null
platform_name: null
platform_version: null
profile: eb-cli
repository: null
sc: null
workspace_type: Application
我运行创建环境的命令行是
eb create <name> -c <name> --elb-type classic
EB CLI 版本信息
eb --version
EB CLI 3.10.5 (Python 2.7.1)