Skip to content

Instantly share code, notes, and snippets.

@cedricziel
Created August 6, 2015 12:03
Show Gist options
  • Save cedricziel/c0e7ef66d3b8e2cec55d to your computer and use it in GitHub Desktop.
Save cedricziel/c0e7ef66d3b8e2cec55d to your computer and use it in GitHub Desktop.
server {
server_name foo.bar;
listen xx.xx.xx.xx;
location / {
if ($http_cf_visitor != '{"scheme":"https"}'){
add_header X-From-NGINX yes;
rewrite ^(.*)$ https://www.foo.bar$1 redirect;
}
proxy_pass http://127.0.0.1:62500;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_buffering off;
proxy_connect_timeout 43200000;
proxy_read_timeout 43200000;
proxy_send_timeout 43200000;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment