3

I have built a rails app and have pushed it to production via heroku. The default address starts with https instead of http. Can I force it to start with http? In my production.rb file, I have the following:

config.force_ssl = false

I also tried to comment out that line, but it still doesn't work. Is there anything else I need to do?

user3575214
  • 3,327
  • 2
  • 14
  • 13
  • have you an SSL certificate? – rogelio Oct 09 '14 at 05:31
  • no any more. I used to have it, but I recently got rid of the certificate and removed the ssl – user3575214 Oct 09 '14 at 05:44
  • see my answer, is very important have one if you need to do this. – rogelio Oct 09 '14 at 05:58
  • There is SSL certificate for `*.herokuapp.com` so as long as you do not use custom domain name (only default Heroku URL e.g. yourapp.herokuapp.com), your website should work fine over HTTP or HTTPS. The redirect which you are trying to make is more related to Ruby-on-rails application - it has to detect HTTP/HTTPS connection and redirect to the required protocol. Please bear in mind that heroku proxies request to your Dyno - so it is always HTTP and you have to find original protocol from HTTP headers - more here: https://devcenter.heroku.com/articles/http-routing – Tom Oct 09 '14 at 11:44

2 Answers2

0

You need to do this basic steps:

  • Purchase an SSL certificate
  • Provision the ssl:endpoint addon heroku addons:add ssl:endpoint
  • Upload your certificate
  • Update your DNS
  • Configure your Rails app with config.force_ssl = true

For more information see this official guide or this another:

rogelio
  • 1,541
  • 15
  • 19
0

When I got this right, you want to force use of http instead of https. I don't know why you would want this and I would not recommend to do so, but you could use the code example from this answer:

class ApplicationController < ActionController::Base
  before_filter do
    if request.ssl? && Rails.env.production?
      redirect_to :protocol => 'http://', :status => :moved_permanently
    end
  end
end
Community
  • 1
  • 1
RobDil
  • 4,036
  • 43
  • 52