Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Nginx config example for Tornado
worker_processes 2;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
}
http {
charset utf-8;
# Enumerate all the Tornado servers here
upstream frontends {
server 127.0.0.1:8000;
server 127.0.0.1:8001;
server 127.0.0.1:8002;
server 127.0.0.1:8003;
}
include /path/to/nginx.mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
keepalive_timeout 65;
proxy_read_timeout 200;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
gzip on;
gzip_min_length 1000;
gzip_proxied any;
gzip_types text/plain text/css text/xml
application/x-javascript application/xml
application/atom+xml text/javascript;
# Only retry if there was a communication error, not a timeout
# on the Tornado server (to avoid propagating "queries of death"
# to all frontends)
proxy_next_upstream error;
server {
listen 80;
location ^~ /static/ {
root /path/to/app;
if ($query_string) {
expires max;
}
}
location / {
proxy_pass_header Server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://frontends;
}
}
}
@shimont

This comment has been minimized.

Copy link

@shimont shimont commented Sep 17, 2013

great, thanks

@fthzkrtn

This comment has been minimized.

Copy link

@fthzkrtn fthzkrtn commented Sep 23, 2013

Very simple and effective thanks!

@chenzhg33

This comment has been minimized.

Copy link

@chenzhg33 chenzhg33 commented Nov 18, 2013

great! , it would be better if you can give comment on some sentences, I really don't know why.

@xros

This comment has been minimized.

Copy link

@xros xros commented Feb 17, 2014

Yeah. Please leave your comments for the codes as the reference. then it could be better.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.