Sergii Mostovyi
Sergii Mostovyi

Reputation: 1451

Rails URL helpers return non-https URLs though default_url_options set to https

I have Nginx serving the SSL. On the rails side it's a Puma and I have config.action_mailer.default_url_options = { protocol: 'https', host: example.com but my root_url still returns http://example.com

Upvotes: 0

Views: 397

Answers (1)

Sergii Mostovyi
Sergii Mostovyi

Reputation: 1451

You need to set proxy_set_header X-Forwarded-Proto https; in your nginx config so Rails would see your request as HTTPS. Here is another issue that is caused by absence of this header - force_ssl would cause endless redirection: https redirect for rails app behind proxy?

UPDATE: X-Forwarded-* headers are considered legacy now. Consider using Forwarded https://www.nginx.com/resources/wiki/start/topics/examples/forwarded/

Upvotes: 2

Related Questions