Enable HTTPS for a Rails app with Kamal to Azure
2024-12-03
Refer to previous two posts to deploy a Rails app to Azure.
- Deploy Rails 7.2.1 + Sqlite3 App to Azure Using Kamal
- Deploy Rails 7.2.1 + Managed Postgresql App to Azure Using Kamal 2.1.1
This post is made for:
- Ruby: 3.3.5
- Rails: 8.0.0
- Kamal: 2.3.0
1. Load Balancer Setup
- Sign into Azure
- Search for Load Balancers and select it.
- Select the load balancer for the VM running the Rails app.
- Select Settings > Inbound NAT rules link in the left sidebar.
- Click +Add
- Create a new NAT inbound rule like below
2. Rails App
Setup the Rails like like the following.
2.1 config/environments/production.rb
config.force_ssl = true
2.2 config/deploy.yml
...
proxy:
ssl: true
host: yourdomain.com
...
2.3 Deploy and Check
- Run
kamal deploy
- Check
yourdomain.com