我正在将客户的网站迁移到AWS。我已经完成了所有配置和工作,但客户希望能够接受网站上的付款。我按照几个指南介绍了如何使用弹性beanstalk进行SSL工作。目前我已将其设置为使用源包,并在.ebextensions文件中创建了一个如下所示的配置文件:
Resources:
sslSecurityGroupIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupName: {Ref : AWSEBSecurityGroup}
IpProtocol: tcp
ToPort: 443
FromPort: 443
CidrIp: 0.0.0.0/0
packages:
yum:
mod24_ssl : []
files:
/etc/httpd/conf.d/ssl.conf:
mode: "000755"
owner: root
group: root
content: |
LoadModule ssl_module modules/mod_ssl.so
Listen 443
<VirtualHost *:443>
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
SSLEngine on
SSLProtocol All -SSLv2 -SSLv3
SSLCertificateFile "/etc/pki/tls/certs/server.crt"
SSLCertificateKeyFile "/etc/pki/tls/certs/server.key"
ProxyPass / http://localhost:80/ retry=0
ProxyPassReverse / http://localhost:80/
ProxyPreserveHost on
LogFormat "%h (%{X-Forwarded-For}i) %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
ErrorLog /var/log/httpd/elasticbeanstalk-error_log
TransferLog /var/log/httpd/elasticbeanstalk-access_log
</VirtualHost>
/etc/pki/tls/certs/server.crt:
mode: "000400"
owner: root
group: root
source: sourceHere
/etc/pki/tls/certs/server.key:
mode: "000400"
owner: root
group: root
source: sourceHere
其中sourceHere是S3中文件的链接,我也尝试直接使用内容代替源,但结果是一样的,应用程序启动时没有任何错误,但尝试连接到IP地址或提供的URL只是说该页面不可用。如果我构建相同的zip文件,但遗漏了配置文件,它正确构建。这几乎就是AWS在那里的支持页面和Elastic Beanstalk的文档,所以我不确定发生了什么。
答案 0 :(得分:8)
不是通过.ebextensions配置SSL,而应该通过Elastic Beanstalk环境配置&gt;&gt;下的Load Balancer来添加它。网络层&gt;&gt;负载平衡。
除了使用CLI工具之外,最简单的方法是创建EC2负载均衡器并添加密钥。一旦您通过第2阶段(选择证书),您就可以中止,并且将保存证书以便Elastic Beanstalk使用。
答案 1 :(得分:2)
配置文件中存在缩进问题:/etc/pki/tls/certs/server.crt
和/etc/pki/tls/certs/server.key
应与/etc/httpd/conf.d/ssl.conf
处于同一级别。
您应该更正缩进,以便获得:
files:
/etc/httpd/conf.d/ssl.conf:
mode: "000755"
owner: root
group: root
content: |
LoadModule ssl_module modules/mod_ssl.so
Listen 443
<VirtualHost *:443>
<Proxy *>
Order deny,allow
Allow from all
</Proxy>
SSLEngine on
SSLProtocol All -SSLv2 -SSLv3
SSLCertificateFile "/etc/pki/tls/certs/server.crt"
SSLCertificateKeyFile "/etc/pki/tls/certs/server.key"
ProxyPass / http://localhost:80/ retry=0
ProxyPassReverse / http://localhost:80/
ProxyPreserveHost on
LogFormat "%h (%{X-Forwarded-For}i) %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\""
ErrorLog /var/log/httpd/elasticbeanstalk-error_log
TransferLog /var/log/httpd/elasticbeanstalk-access_log
</VirtualHost>
/etc/pki/tls/certs/server.crt:
mode: "000400"
owner: root
group: root
source: sourceHere
/etc/pki/tls/certs/server.key:
mode: "000400"
owner: root
group: root
source: sourceHere
答案 2 :(得分:0)
如果你想使用letsencrypt,可以尝试这样做:这是在单实例弹性beanstalk节点服务器上安装证书的方法:http://bluefletch.com/blog/domain-agnostic-letsencrypt-ssl-config-for-elastic-beanstalk-single-instances/
基本上是一个自动.ebextension来安装certbot,获取证书,并将nginx链接到它。