After another whole day struggle and 50+ deploys I’m not getting anywhere.
I created a separate EB app and environment for this because my git repository is getting too much polluted.
I created a domain ssl-test.naguras.com that points to ssltest-env.mmxzzbys7m.us-east-1.elasticbeanstalk.com
This works and both domains return “Hello World” when queried in the browser.
The content of the config file in .ebextensions is:
# (!) Based on : https://gist.github.com/tony-gutierrez/198988c34e020af0192bab543d35a62a
# Dont forget to set the env variable "CERTDOMAIN" and "EMAIL"
# Also note that this config is using the LetsEncrypt staging server, remove the flag when ready!
Resources:
sslSecurityGroupIngress:
Type: AWS::EC2::SecurityGroupIngress
Properties:
GroupId: {"Fn::GetAtt" : ["AWSEBSecurityGroup", "GroupId"]}
IpProtocol: tcp
ToPort: 443
FromPort: 443
CidrIp: 0.0.0.0/0
files:
# Allow verification to perform the challenge
/etc/nginx/conf.d/allow_LetsEncrypt_verification.conf:
mode: "000644"
owner: root
group: root
content: |
server {
listen 8080;
location ~ /.well-known/acme-challenge/ {
root /var/www/acme-challenge/;
}
}
packages:
yum:
epel-release: []
container_commands:
10_installcertbot:
command: "sudo mkdir -p /opt/certbot && wget https://dl.eff.org/certbot-auto -O /opt/certbot/certbot-auto"
20_Setpermissions:
command: "sudo chown root /opt/certbot/certbot-auto;sudo chmod 0755 /opt/certbot/certbot-auto"
30_createwebrootpath:
command: "sudo mkdir -p /var/www/acme-challenge"
40_getcertwebrootmode:
command: "sudo /opt/certbot/certbot-auto certonly --debug --non-interactive --email ${EMAIL} --agree-tos --authenticator webroot --webroot-path /var/www/acme-challenge --domains ${CERTDOMAIN} --keep-until-expiring --staging --installer nginx"
50_config:
command: "sudo mv /etc/nginx/conf.d/https_custom.pre /etc/nginx/conf.d/https_custom.conf"
60_link:
command: "sudo ln -sf /etc/letsencrypt/live/${CERTDOMAIN} /etc/letsencrypt/live/ebcert"
and the log files says this:
[2019-06-23T11:54:25.752Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/AppDeployPreHook/60config_generate.sh] : Starting activity...
[2019-06-23T11:54:27.365Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/AppDeployPreHook/60config_generate.sh] : Completed activity. Result:
+ /opt/elasticbeanstalk/containerfiles/ebnode.py --action generate-config
Generating modifications to /etc/nginx/nginx.conf
Generating reverse proxy settings
[2019-06-23T11:54:27.365Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/AppDeployPreHook] : Completed activity. Result:
Successfully execute hooks in directory /opt/elasticbeanstalk/hooks/appdeploy/pre.
[2019-06-23T11:54:27.365Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/EbExtensionPostBuild] : Starting activity...
[2019-06-23T11:54:27.748Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Starting activity...
[2019-06-23T11:54:27.752Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ssl_test] : Starting activity...
[2019-06-23T11:54:28.584Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ssl_test/Command 10_installcertbot] : Starting activity...
[2019-06-23T11:54:28.702Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ssl_test/Command 10_installcertbot] : Completed activity. Result:
--2019-06-23 11:54:28-- https://dl.eff.org/certbot-auto
Resolving dl.eff.org (dl.eff.org)... 151.101.248.201, 2a04:4e42:3b::201
Connecting to dl.eff.org (dl.eff.org)|151.101.248.201|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 68023 (66K) [application/octet-stream]
Saving to: '/opt/certbot/certbot-auto'
0K .......... .......... .......... .......... .......... 75% 59.2M 0s
50K .......... ...... 100% 252M=0.001s
2019-06-23 11:54:28 (73.0 MB/s) - '/opt/certbot/certbot-auto' saved [68023/68023]
[2019-06-23T11:54:29.530Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ssl_test/Command 20_Setpermissions] : Starting activity...
[2019-06-23T11:54:29.541Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ssl_test/Command 20_Setpermissions] : Completed activity.
[2019-06-23T11:54:30.374Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ssl_test/Command 30_createwebrootpath] : Starting activity...[2019-06-23T11:54:30.380Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ssl_test/Command 30_createwebrootpath] : Completed activity. [2019-06-23T11:54:31.210Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ssl_test/Command 40_getcertwebrootmode] : Starting activity...
[2019-06-23T11:54:34.136Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ssl_test/Command 40_getcertwebrootmode] : Activity execution failed, because: Saving debug log to /var/log/letsencrypt/letsencrypt.log
Plugins selected: Authenticator webroot, Installer nginx
Obtaining a new certificate
Performing the following challenges:
http-01 challenge for ssl-test.naguras.com
Using the webroot path /var/www/acme-challenge for all unmatched domains.
Waiting for verification...
Challenge failed for domain ssl-test.naguras.com
http-01 challenge for ssl-test.naguras.com
Cleaning up challenges
Exiting abnormally:
Traceback (most recent call last):
File "/opt/eff.org/certbot/venv/bin/letsencrypt", line 11, in <module>
sys.exit(main())
File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/main.py", line 1379, in main
return config.func(config, plugins)
File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/main.py", line 1262, in certonly
lineage = _get_and_save_cert(le_client, config, domains, certname, lineage)
File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/main.py", line 120, in _get_and_save_cert
lineage = le_client.obtain_and_enroll_certificate(domains, certname)
File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/client.py", line 406, in obtain_and_enroll_certificate
cert, chain, key, _ = self.obtain_certificate(domains)
File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/client.py", line 349, in obtain_certificate
orderr = self._get_order_and_authorizations(csr.data, self.config.allow_subset_of_names)
File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/client.py", line 385, in _get_order_and_authorizations
authzr = self.auth_handler.handle_authorizations(orderr, best_effort)
File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/auth_handler.py", line 90, in handle_authorizations
self._poll_authorizations(authzrs, max_retries, best_effort)
File "/opt/eff.org/certbot/venv/local/lib/python2.7/site-packages/certbot/auth_handler.py", line 154, in _poll_authorizations
raise errors.AuthorizationError('Some challenges have failed.')
AuthorizationError: Some challenges have failed.
Please see the logfiles in /var/log/letsencrypt for more details.
IMPORTANT NOTES:
- The following errors were reported by the server:
Domain: ssl-test.naguras.com
Type: unauthorized
Detail: Invalid response from
http://ssl-test.naguras.com/.well-known/acme-challenge/d1y452Gx9qyL_xh-qFNkCeeZL5Kg5oR55EWkbLKGRAM
[3.93.250.159]: "<!DOCTYPE html>\n<html lang=\"en\">\n<head>\n<meta
charset=\"utf-8\">\n<title>Error</title>\n</head>\n<body>\n<pre>Cannot
GET /.well-known/"
To fix these errors, please make sure that your domain name was
entered correctly and the DNS A/AAAA record(s) for that domain
contain(s) the right IP address.
(ElasticBeanstalk::ExternalInvocationError)
[2019-06-23T11:54:34.136Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ssl_test/Command 40_getcertwebrootmode] : Activity failed.
[2019-06-23T11:54:34.136Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild/postbuild_0_ssl_test] : Activity failed.
[2019-06-23T11:54:34.136Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/EbExtensionPostBuild/Infra-EmbeddedPostBuild] : Activity failed.
[2019-06-23T11:54:34.158Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0/EbExtensionPostBuild] : Activity failed.
[2019-06-23T11:54:34.158Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11/AppDeployStage0] : Activity failed.
[2019-06-23T11:54:34.158Z] INFO [2971] - [Application update app-v1_0_11-190623_185330@11] : Completed activity. Result:
Application update - Command CMD-AppDeploy failed
Below is a list of the files in /etc/nginx/conf.d so the confog files made it to the server.
[ec2-user@ip-172-31-92-198 ~]$ sudo ls -al /etc/nginx/conf.d
total 36
drwxr-xr-x 2 root root 4096 Jun 23 10:59 .
drwxr-xr-x 4 root root 4096 Jun 23 10:42 ..
-rw-r--r-- 1 root root 1351 Jun 23 09:56 00_elastic_beanstalk_proxy.conf
-rw-r--r-- 1 root root 111 Jun 23 10:59 allow_LetsEncrypt_verification.conf
-rw-r--r-- 1 root root 136 Jun 23 10:27 allow_LetsEncrypt_verification.conf.bak
-rw-r--r-- 1 root root 1204 Jun 23 10:50 https_custom.conf
-rw-r--r-- 1 root root 1022 Jun 23 10:59 https_custom.pre
-rw-r--r-- 1 root root 1022 Jun 23 10:27 https_custom.pre.bak
-rw-r--r-- 1 root root 283 Dec 13 2018 virtual.conf