stack twitter rss linkedin cross

Wilco van Esch

Skip to main content

Search results

    Enabling a Let's Encrypt SSL certificate on a Rails app hosted on Heroku with a Namecheap DNS

    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

    1. Log in to your Heroku account
    2. Select the app you want to set an SSL certificate for
    3. Go to Settings
    4. Scroll to Domains and certificates
    5. Click Configure SSL
    6. Choose Automatically configure using Automated Certificate Management
    7. Click Continue

    Namecheap

    1. Log in to your Namecheap account
    2. Go to the Dashboard
    3. For your app's domain, select Manage
    4. Go to Advanced DNS
    5. Change the CNAME Record for Host www to www.yourdomain.com.herokudns.com
    6. Save your change

    Heroku again

    1. Click I've done this for the DNS settings change
    2. Click Continue
    3. 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

    1. Edit config\environments\production.rb in your Rails app
    2. Find the config.force_ssl toggle
    3. Set config.force.ssl = true
    4. 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.