This example shows how you can terminate HTTPS in your Elastic Beanstalk environment.
- ACM certifacte to attach your EB Load Balancer
- Update https-lb-terminate.config with your ACM ceritifacate ARN
- Update https.config with your desired domain in both server blocks.
- Create an Elastic Beanstalk environment
$ eb create redirect-apex -p "64bit Amazon Linux 2017.09 v4.4.6 running Node.js"
Or if you have an environment already created.
$ git add .
$ git commint -m "terminate https! and redirect to one domain!"
$ eb deploy
Note: this config is specific to Nodejs with an Nginx proxy configured. Feel free to change as required for your solution stack
# verify that http://WWW. goes to https://apex
$ curl -I http://www.mydomain.com
HTTP/1.1 301 Moved Permanently
Date: Wed, 04 Apr 2018 12:00:50 GMT
Location: https://mydomain.com/
Server: nginx/1.12.1
Content-Length: 185
Content-Type: text/html
Via: 1.1 iad6-proxy-5.amazon.com:80 (Cisco-WSA/10.5.1-296)
Connection: keep-alive
# verify that https://WWW. goes to https://apex
$ curl -I https://www.mydomain.com
HTTP/1.1 301 Moved Permanently
Date: Wed, 04 Apr 2018 12:00:50 GMT
Location: https://mydomain.com/
Server: nginx/1.12.1
Content-Length: 185
Content-Type: text/html
Via: 1.1 iad6-proxy-5.amazon.com:80 (Cisco-WSA/10.5.1-296)
Connection: keep-alive
# verify that http://APEX goes to https://apex
$ curl -I http://mydomain.com
HTTP/1.1 301 Moved Permanently
Date: Wed, 04 Apr 2018 12:00:50 GMT
Location: https://mydomain.com/
Server: nginx/1.12.1
Content-Length: 185
Content-Type: text/html
Via: 1.1 iad6-proxy-5.amazon.com:80 (Cisco-WSA/10.5.1-296)
Connection: keep-alive
# finally, verify that that https://apex repond 200 OK
$ curl -I https://mydomain.com
HTTP/1.1 200 OK
Content-Length: 16
Content-Type: text/html; charset=utf-8
Date: Wed, 04 Apr 2018 12:01:54 GMT
ETag: W/"10-8csYTHwr/fSeZx//reF9Ref6bTE"
Server: nginx/1.12.1
X-Powered-By: Express
Connection: keep-alive