On heroku, is there absolutely no way to redirect an https naked domain on heroku to it's non naked domain with wwws?

MintDeparture picture MintDeparture · Sep 2, 2012 · Viewed 7.1k times · Source

Have a look at this link from the Heroku docs:

https://devcenter.heroku.com/articles/avoiding-naked-domains-dns-arecords#subdomain-redirection

The yellow boxes says:

Requests made directly to naked domains via SSL (i.e. https://mydomain.com) will encounter a warning when using subdomain redirection. This is expected and can be avoided by only circulating and publicizing the subdomain format of your secure URL.

Is that really the only solution? Just hope that people don't type in the url without the wwws?

I've had several problems with people just removing the sub-domain from the url to get to the homepage (on https) and encountering an ssl warning?

Has anyone else figured out a way around this?

Answer

maletor picture maletor · Sep 9, 2012

The best idea we have found so far is to setup two Amazon EC2 micro machine instances with a small bit of nginx configuration. Then, provision two elastic IP addresses to point to those EC2 instances and point 2 A records to those IP addresses. This way, if something goes wrong on the hardware, you can always point your elastic IPs at another EC2 machine without waiting for DNS to propagate. Users going to https://example.com and http://example.com will get a 301 to the domain and no SSL warning.

server {
  listen 80;
  listen 443 default_server ssl;
  server_name example.com;
  ssl_certificate server.crt;
  ssl_certificate_key server.key;
  return 301 https://www.example.com$request_uri;
}

Another idea is to use the great service provided by wwwizer.