- Create dockerized NextJS app - part 1
- Deploy dockerized app to AWS EB - part 2
- Connect custom domain to our application - previous part
In this part we are going to set up redirects from http to https (for security reasons) and from www to non-www (for SEO reasons).
Everything in here is within AWS Free tier.
Also please pay attention that all links to AWS I provide use my region of choice, if you're using different AWS region make sure to change it before making any changes!
To set up redirects we need to open EC2 Load Balancers Console, select our balancer and open
We will start with redirecting http to https:
- Switch to
Edit rulesmode - open Pen tab
- Click on Pen icon on the left of
HTTP 80: default action
- Delete default action in
- Enter port
443on the right of protocol dropdown and click check icon to save changes
Next we will redirect www to non-www:
- Switch to
- Enter port 443 and save changes
We also want to set redirection from www to non-www on https connections:
- Go back to Listeners tab
View/edit rulesin HTTPS row
- Add new rule:
IFhost header is
- Set port 443
Origin host, path, queryto
- Replace value of
Hostfield with your website domain
- Save changes.
You now have fully functional https website that is being served completely free of charge (within Free tier quota of course).
Hope you liked the series. Bye-bye =)