Tutorial: Adding https to a custom domain on Elastic Beanstalk

If you select the ELB target, it will work until the environment changes and the ELB is reconfigured. I learned this the hard way.

Bonus Tip: Redirecting http to https at the Apache level.

files:
"/etc/httpd/conf.d/ssl_rewrite.conf":
mode: "000644"
owner: root
group: root
content: |
RewriteEngine On
<If "-n '%{HTTP:X-Forwarded-Proto}' && %{HTTP:X-Forwarded-Proto} != 'https'">
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} [R,L]
</If>

Note! YAML uses spaces, not tabs, so make sure you use spaces in the snippet above or you will get a cryptic error message.

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store