This guide applies if you want to secure the Namecheap domain for your Rails app with a free Let's Encrypt SSL certificate and force HTTP access to HTTPS.
The following steps were last verified as valid on 21 April 2017.
Heroku
- Log in to your Heroku account
- Select the app you want to set an SSL certificate for
- Go to Settings
- Scroll to Domains and certificates
- Click Configure SSL
- Choose Automatically configure using Automated Certificate Management
- Click Continue
Namecheap
- Log in to your Namecheap account
- Go to the Dashboard
- For your app's domain, select Manage
- Go to Advanced DNS
- Change the CNAME Record for Host www to www.yourdomain.com.herokudns.com
- Save your change
Heroku again
- Click I've done this for the DNS settings change
- Click Continue
- Wait for the changes to take effect. You can use Refresh status to view progress or
curl -vI https://www.yourdomain.com
for more detail
Now the SSL certificate should be applied to your domain.
Rails
- Edit
config\environments\production.rb
in your Rails app - Find the
config.force_ssl
toggle - Set
config.force.ssl = true
- Deploy the change
Now if you go to yourdomain.com or www.yourdomain.com you'll be brought to https://www.yourdomain.com and the browser's certificate verification will indicate a secure connection.