Created
May 26, 2014 04:53
-
-
Save allanlei/38c72362651ae9578253 to your computer and use it in GitHub Desktop.
Sample python backend for nginx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
server { | |
listen 80 default_server deferred; | |
listen 443 default_server deferred ssl; | |
listen [::]:80 ipv6only=on default_server deferred; | |
listen [::]:443 ipv6only=on default_server deferred ssl; | |
server_name example.com www.example.com testing.example.com; | |
root /path/to/static/files | |
# Include SSL stuff | |
location / { | |
location ~* \.(css|gif|ico|jpe?g|js[on]?p?|png|svg|txt|xml)$ { | |
access_log off; | |
add_header Cache-Control "public"; | |
add_header Pragma "public"; | |
expires 365d; | |
log_not_found off; | |
tcp_nodelay off; | |
open_file_cache max=16 inactive=600s; # 10 minutes | |
open_file_cache_errors on; | |
open_file_cache_min_uses 2; | |
open_file_cache_valid 300s; # 5 minutes | |
} | |
try_files $uri @gunicorn; | |
} | |
location @gunicorn { | |
add_header X-Proxy-Cache $upstream_cache_status; | |
expires epoch; | |
proxy_cache proxy; | |
proxy_cache_bypass $nocache; | |
proxy_cache_key "$request_method@$scheme://$server_name:$server_port$uri$args"; | |
proxy_cache_lock on; | |
proxy_cache_lock_timeout 2000; | |
proxy_cache_use_stale error timeout invalid_header updating http_500; | |
proxy_cache_valid 200 302 1m; | |
proxy_cache_valid 301 1D; | |
proxy_cache_valid any 5s; | |
proxy_http_version 1.1; | |
proxy_ignore_headers Cache-Control Expires; | |
proxy_max_temp_file_size 1m; | |
proxy_no_cache $nocache; | |
proxy_redirect off; | |
proxy_set_header Host $host; | |
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; | |
proxy_set_header X-Real-IP $remote_addr; | |
proxy_pass http://gunicorn; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment