Permalink
Browse files

Add an nginx conf that proxies to gunicorn

  • Loading branch information...
1 parent 90f3833 commit 824014325578c60b5d755539b349b4c10899c64d @zain committed Feb 12, 2012
Showing with 61 additions and 0 deletions.
  1. +61 −0 nginx.conf
View
@@ -0,0 +1,61 @@
+worker_processes 2;
+
+error_log /var/log/nginx/error.log;
+
+events {
+ worker_connections 1024;
+ accept_mutex off;
+}
+
+
+http {
+ include mime.types;
+ default_type application/octet-stream;
+
+ #log_format main '$remote_addr - $remote_user [$time_local] "$request" '
+ # '$status $body_bytes_sent "$http_referer" '
+ # '"$http_user_agent" "$http_x_forwarded_for"';
+
+ log_format main '$status @ [$time_local] time:[$upstream_response_time $request_time] size:$body_bytes_sent ~ "$request"';
+
+ access_log /var/log/nginx/access.log main;
+
+ sendfile on;
+
+ upstream app_server {
+ server 127.0.0.1:8000 fail_timeout=0;
+ }
+
+ server {
+ listen 8080;
+ server_name localhost;
+ client_max_body_size 4G;
+
+ keepalive_timeout 5;
+
+
+ # path for static files
+ root /Users/zain/projects/nginx_root/;
+
+ location / {
+ autoindex on;
+ # checks for static file, if not found proxy to app
+ try_files $uri @proxy_to_app;
+ }
+
+ location @proxy_to_app {
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
+ proxy_set_header Host $http_host;
+ proxy_redirect off;
+
+ proxy_pass http://app_server;
+ }
+
+ error_page 500 502 503 504 /500.html;
+ location = /500.html {
+ root /Users/zain/projects/nginx_root/;
+ }
+
+ } # end of server
+
+}

0 comments on commit 8240143

Please sign in to comment.