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
Asked
Active
Viewed 317 times
0

Sergii Mostovyi
- 1,361
- 1
- 15
- 19
1 Answers
2
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/

Sergii Mostovyi
- 1,361
- 1
- 15
- 19
-
can you share ur complete nginx config? where to put this proxy_set_header ? – buncis Apr 13 '23 at 23:10
-
@buncis here is a general config example http://nginx.org/en/docs/example.html Here is a newer solution btw (I've updated the answer) https://www.nginx.com/resources/wiki/start/topics/examples/forwarded/ – Sergii Mostovyi Apr 20 '23 at 13:20