ssl - How to ensure HTTPS root domain requests are redirected to www for Heroku -
ssl - How to ensure HTTPS root domain requests are redirected to www for Heroku -
i'm using wildcard certificate heroku rails 4.2 project provides users subdomains accounts. i've got working have few kinks iron out.
if type http://example.com in brower, get's redirected https://www.example.com , resolves fine.
however if type https://example.com next in browser
unable connect. firefox can't found connection server @ mydomain.com. site temporarily unavailable or busy. seek 1 time again in few moments....
these dns settings
@ ----> http://www.example.com url-redirect (this intentional - heroku cant utilize naked domains ssl)
www ----> blahblah-1234.herokussl.com cname
subdomains
* ----> blahblah-1234.herokussl.com. cname
as dns 'url-redirect' mentioned above have configured rails rewrite rootdomain requests. (i dont think reqest hitting rails though)
i have created middleware rewrite requests 'example.com' 'www.example.com' , inserted before actiondispatch::ssl
class roottowww def initialize(app) @app = app end def call(env) request = rack::request.new(env) if request.host.starts_with?('myexample.com') [301, {"location" => request.url.sub("//", "//www.")}, self] else @app.call(env) end end def each(&block) end end # in production.rb config.middleware.insert_before 'actiondispatch::ssl', 'roottowww'
can explain how can ensure https requests root domains redirected www?
firefox can't found connection
this means can not found tcp connection port 443 on server example.com
. either there no ssl server running domain on ip address provided example.com
or firewall blocks connection.
these dns settings
@ ----> http://www.example.com url-redirect (this intentional - heroku cant utilize naked domains ssl)
a url redirect not dns thing, needs have web server @ example.com
http redirect www.example.com
. based on comment heroku can't deal ssl on naked domains suggest, example.com
, www.example.com
different web servers , on different ip addresses. in case not able utilize ssl naked domain because webserver on naked domain not ssl @ all, i.e. not hear on port 443 connection , "firefox can't found connection". , if cannot utilize ssl on naked domain can not redirect https either, because redirect needs first established ssl connection.
ssl heroku dns
Comments
Post a Comment