Force SSL for Heroku apps running in EU region Force SSL for Heroku apps running in EU region heroku heroku

Force SSL for Heroku apps running in EU region


production.rb

Rails.application.configure do    config.force_ssl = trueend

This will redirect all http traffic to https

Edit: Its worth noting that this is a Rails thing rather than a heroku one.

Revision:

As this answer/question regularly gets seen and upvoted, it's also possible within a controller on a per request basis:

class AccountsController < ApplicationController  force_ssl if: :ssl_configured?  def ssl_configured?    !Rails.env.development?  endend


FYI your question mentions herokussl.com which is part of the deprecated Heroku SSL Endpoint service. Heroku now recommends using the Heroku SSL service:

The SSL Endpoint add-on is only recommended if you need to support legacy browser clients which do not support SNI. Our default recommendation is to use the Heroku SSL described in this document.

Also note that appname.herokuapp.com domains are already SSL-enabled and can be accessed by using https, for example, https://appname.herokuapp.com.