Issues trying to configure SSL on AWS Elastic Beanstalk Webserver (single instance) PHP

我怕爱的太早我们不能终老 提交于 2019-12-03 14:25:37

There is a problem of indentation in your config file: /etc/pki/tls/certs/server.crt and /etc/pki/tls/certs/server.key should be at the same level as /etc/httpd/conf.d/ssl.conf.

You should correct the indentation so you get:

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

Instead of provisioning SSL via .ebextensions you should look at adding it via the Load Balancer under the Elastic Beanstalk Environment configuration >> Networking Tier >> Load Balancing.

The easiest way, other than using the CLI tools, is to create a EC2 load balancer and add the keys. Once you pass stage 2 (Select Certificate) then you can abort and the certificate will be save for Elastic Beanstalk usage.

  1. Create Load Balancer
  2. Add HTTPS

  1. Add Private Key, Public Key Certificate, Certificate Chain.
  2. Continue, then abort.
  3. The SSL Certificate will now be available in your Elastic Beanstalk Environment.

If you want to use letsencrypt you can try this: Heres a way to install certs on single instance elastic beanstalk node servers: http://bluefletch.com/blog/domain-agnostic-letsencrypt-ssl-config-for-elastic-beanstalk-single-instances/

Basically an automated .ebextension to install certbot, get a cert, and link nginx to it.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!