Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I have a Sinatra app running in nginx (using thin as a back-proxy) and I'm using redirect '/<path>' statements in Sinatra. However, when I access the site under https, those redirects send me to http://localhost/<path> rather than to https://localhost/<path> as they should.

Currently, nginx passes control to thin with this command proxy_pass http://thin_cluster, where thin_cluster is

upstream thin_cluster { server unix:/tmp/thin.cct.0.sock; }

How can I fix this?

share|improve this question

2 Answers 2

Try this:

redirect "https://#{request.host}/<path>"

Sinatra is lightweight, it does not have any detection for this by default i guess.

share|improve this answer

You should be able to achieve this with the proxy_redirect directive. If proxy_redirect default doesn't work (it should be the default setting), try something like this:

proxy_redirect http://localhost/ https://localhost/;
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.