lunedì 14 luglio 2014

How to force HTTPS on Openshift for Rails applications

RedHat OpenShift provides the possibility to enable HTTPS for your Rails application.

By default your Rails application will be available on

http://appname-domain.rhcloud.com

and

https://appname-domain.rhcloud.com

In my applications I want every request to be handled by HTTPS. In order to achieve that add to your public directory a .htaccess file with the below content


RewriteEngine on


RewriteCond %{HTTP:X-Forwarded-Proto} !https

RewriteRule .* https://%{HTTP_HOST}%{REQUEST_URI} [R,L]


For additional information for non-Apache based applications check OpenShift article out