Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSL website in rails forwards me to a url with port 443 suffix

First off, this is my first SSL web application so I might be doing something horribly wrong. We turned on SSL per request from a client on https://bla.be/

It seemed to work out of the box. We ordered web hosting with SSL and we didn't seem to have to do any configuration.

However 2 problems arose:

  1. Whenever I click certain links (and it really seems random as to which ones) it deforms the url prefix from HTTPS to HTTP and adds a port :443 suffix at the end of the domain name. Resulting in links that do not work. (ex.: https://bla.com/view/3 becomes http://bla.com:443/view/3)
  2. It always does this when I download a file through sendfile:

    send_file datafile.document.path, :type => datafile.document_content_type, :disposition => 'attachment', :x_sendfile => true

I tried adding :secure => true to links but that doesn't seem to do anything.

Am I forgetting some required configuration? Or is my host's setup wrong?

Thanks in advance.

like image 988
Steven De Coeyer Avatar asked Nov 05 '22 03:11

Steven De Coeyer


1 Answers

It sounds like you're specifying the :port option on your URL generation instead of the :protocol. You want to switch to the https protocol, not specify the SSL port.

If you're using a library/gem for this, it's not working correctly.

I'd recommend the ssl_requirement plugin.

like image 90
Winfield Avatar answered Nov 09 '22 16:11

Winfield