|
| 1 | +upstream hello_app_server { |
| 2 | + server unix:/var/www/DjangoBlog/run/gunicorn.sock fail_timeout=0; |
| 3 | +} |
| 4 | + |
| 5 | +server { |
| 6 | + |
| 7 | + |
| 8 | + server_name blog.lylinux.org; |
| 9 | + root /var/www/DjangoBlog/; |
| 10 | + |
| 11 | + listen 80; |
| 12 | + |
| 13 | + keepalive_timeout 70; |
| 14 | + access_log off; |
| 15 | + |
| 16 | + location /static/ { |
| 17 | + alias /var/www/DjangoBlog/blog/static/; |
| 18 | + } |
| 19 | + |
| 20 | + location ~* ^.+.(jpg|jpeg|gif|png|ico|css|zip|tgz|gz|rar|bz2|doc|xls|exe|pdf|ppt|txt|tar|mid|midi|wav|bmp|rtf|js)$ { |
| 21 | + expires max; |
| 22 | + } |
| 23 | + location / { |
| 24 | +# an HTTP header important enough to have its own Wikipedia entry: |
| 25 | +# http://en.wikipedia.org/wiki/X-Forwarded-For |
| 26 | + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; |
| 27 | + |
| 28 | +# enable this if and only if you use HTTPS, this helps Rack |
| 29 | +# set the proper protocol for doing redirects: |
| 30 | +# proxy_set_header X-Forwarded-Proto https; |
| 31 | + |
| 32 | +# pass the Host: header from the client right along so redirects |
| 33 | +# can be set properly within the Rack application |
| 34 | + proxy_set_header Host $http_host; |
| 35 | + |
| 36 | +# we don't want nginx trying to do something clever with |
| 37 | +# redirects, we set the Host: header above already. |
| 38 | + proxy_redirect off; |
| 39 | + |
| 40 | +# set "proxy_buffering off" *only* for Rainbows! when doing |
| 41 | +# Comet/long-poll stuff. It's also safe to set if you're |
| 42 | +# using only serving fast clients with Unicorn + nginx. |
| 43 | +# Otherwise you _want_ nginx to buffer responses to slow |
| 44 | +# clients, really. |
| 45 | +# proxy_buffering off; |
| 46 | + |
| 47 | +# Try to serve static files from nginx, no point in making an |
| 48 | +# *application* server like Unicorn/Rainbows! serve static files. |
| 49 | + if (!-f $request_filename) { |
| 50 | + proxy_pass http://hello_app_server; |
| 51 | + break; |
| 52 | + } |
| 53 | + } |
| 54 | + |
| 55 | +} |
0 commit comments