Skip to content

Instantly share code, notes, and snippets.

@cdvel
Last active April 30, 2018 09:37
Show Gist options
  • Select an option

  • Save cdvel/f522b7d69cbffeb7cf1c8cd488c267cd to your computer and use it in GitHub Desktop.

Select an option

Save cdvel/f522b7d69cbffeb7cf1c8cd488c267cd to your computer and use it in GitHub Desktop.
Basic nginx proxy for Tornado (etc) MacOS
# 1. serve tornado in port 5000 e.g., tornado_server.py
# 2. add tornado configuration to /usr/local/etc/nginx/nginx.conf, inside http block
upstream tornado {
server 127.0.0.1:80 max_fails=3 fail_timeout=1s;
}
server {
listen 80;
server_name localhost;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_set_header Host $host;
proxy_pass http://127.0.0.1:5000;
proxy_redirect default;
proxy_redirect http://127.0.0.1:80/ /;
}
}
# 3. reload config file with `sudo nginx -s reload`
# 4. `python tornado_server.py`, and open http://localhost
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment