Skip to content

Instantly share code, notes, and snippets.

@kuleszaj
Created February 25, 2012 21:53
Show Gist options
  • Save kuleszaj/1911050 to your computer and use it in GitHub Desktop.
Save kuleszaj/1911050 to your computer and use it in GitHub Desktop.
Nginx with X-Forwarded-Proto set for SSL
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;
}
}
@om-ha
Copy link

om-ha commented Nov 3, 2022

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.

@jamallmahmoudi
Copy link

proxy_set_header X-Forwarded-Proto https;
proxy_set_header X-Forwarded-Scheme https;

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment