Created
February 25, 2012 21:53
-
-
Save kuleszaj/1911050 to your computer and use it in GitHub Desktop.
Nginx with X-Forwarded-Proto set for SSL
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 1.2.3.4:443; | |
server_name railsapp.example.com; | |
ssl on; | |
ssl_certificate cert.pem; | |
ssl_certificate_key cert.key; | |
location / { | |
proxy_set_header X-Forwarded-Proto https; | |
# Sets the HTTP headers appropiately; | |
proxy_pass http://rails_application; | |
} | |
} |
I would rather opt-in for using $scheme
so you don't pull your hair when using the wrong protocol in the server location block when copy-pasting configs around:
proxy_set_header X-Forwarded-Proto $scheme;
NGINX Source $scheme.
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Scheme https;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Scheme https;
This helped me a lot. I was using
proxy_set_header X-Forwarded-Proto $scheme;
But for some reason $scheme
was getting http
value, so when using hard-coded https
value, solved. Thanks.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If using Laravel, need to configure trusted proxies list in TrustProxies MiddleWare
https://laravel.com/docs/8.x/requests#configuring-trusted-proxies