Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Add an nginx conf that proxies to gunicorn

  • Loading branch information...
commit 824014325578c60b5d755539b349b4c10899c64d 1 parent 90f3833
Zain Memon authored February 12, 2012

Showing 1 changed file with 61 additions and 0 deletions. Show diff stats Hide diff stats

  1. 61  nginx.conf
61  nginx.conf
... ...
@@ -0,0 +1,61 @@
  1
+worker_processes  2;
  2
+
  3
+error_log  /var/log/nginx/error.log;
  4
+
  5
+events {
  6
+    worker_connections  1024;
  7
+    accept_mutex off;
  8
+}
  9
+
  10
+
  11
+http {
  12
+    include       mime.types;
  13
+    default_type  application/octet-stream;
  14
+
  15
+    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
  16
+    #                  '$status $body_bytes_sent "$http_referer" '
  17
+    #                  '"$http_user_agent" "$http_x_forwarded_for"';
  18
+    
  19
+    log_format main '$status @ [$time_local] time:[$upstream_response_time $request_time] size:$body_bytes_sent  ~ "$request"';
  20
+    
  21
+    access_log  /var/log/nginx/access.log  main;
  22
+
  23
+    sendfile    on;
  24
+    
  25
+    upstream app_server {
  26
+        server 127.0.0.1:8000 fail_timeout=0;
  27
+    }
  28
+    
  29
+    server {
  30
+        listen       8080;
  31
+        server_name  localhost;
  32
+        client_max_body_size 4G;
  33
+        
  34
+        keepalive_timeout 5;
  35
+        
  36
+        
  37
+        # path for static files
  38
+        root /Users/zain/projects/nginx_root/;
  39
+
  40
+        location / {
  41
+            autoindex on;
  42
+            # checks for static file, if not found proxy to app
  43
+            try_files $uri @proxy_to_app;
  44
+        }
  45
+        
  46
+        location @proxy_to_app {
  47
+            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  48
+            proxy_set_header Host $http_host;
  49
+            proxy_redirect off;
  50
+
  51
+            proxy_pass   http://app_server;
  52
+        }
  53
+
  54
+        error_page 500 502 503 504 /500.html;
  55
+        location = /500.html {
  56
+            root /Users/zain/projects/nginx_root/;
  57
+        }
  58
+
  59
+    } # end of server
  60
+    
  61
+}

0 notes on commit 8240143

Please sign in to comment.
Something went wrong with that request. Please try again.