Created
September 25, 2013 12:31
-
-
Save nebadon2025/6698986 to your computer and use it in GitHub Desktop.
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
user nginx; | |
worker_processes 5; | |
pid /var/run/nginx.pid; | |
events { | |
worker_connections 1024; | |
} | |
http { | |
include mime.types; | |
default_type application/octet-stream; | |
log_format main '$remote_addr - $remote_user [$time_local] "$request" ' | |
'$status $body_bytes_sent $upstream_response_time "$http_referer" ' | |
'"$http_user_agent" "$http_x_forwarded_for"'; | |
# | |
# settings for asset data cache. | |
# | |
proxy_cache_path /home/assets/nginx/cache levels=2:2 keys_zone=assets:60m max_size=20000m; | |
proxy_temp_path /home/assets/nginx/cache/tmp; | |
sendfile on; | |
#tcp_nopush on; | |
keepalive_timeout 180; | |
gzip off; | |
# | |
# throttle to 10 requests per second per IP. | |
# | |
limit_req_zone $binary_remote_addr zone=one:50m rate=10r/s; | |
# | |
# this upstream goes to sras2 on the new asset box, and if that | |
# fails tries sras2 on the old asset box, and if that fails tries | |
# the original sras1 on the old asset box. | |
# | |
upstream osgrid_sras_mix { | |
server 127.0.0.1:10004; # sras2 on new box | |
server hutto.osgrid.org:80 backup; # sras2+sras1 on old box | |
} | |
# | |
# this upstream goes to sras2 on the new box only. used for | |
# creating new assets until everything is migrated. | |
# | |
upstream osgrid_sras2_prod { | |
server 127.0.0.1:10004; # sras2 on new box | |
} | |
server { | |
listen 80 default_server; | |
listen 8099; | |
server_name taweret.osgrid.org; | |
include /etc/nginx/ipblock.conf; | |
keepalive_timeout 180 120; | |
keepalive_requests 100; | |
proxy_ignore_client_abort on; | |
client_max_body_size 100m; | |
# | |
# the below line throttles incoming requests to 10 reqs/second | |
# per source IP address, and will queue up to 100 requests | |
# above that threshold. To disable, just comment out this | |
# line and run '/etc/init.d/nginx reload' | |
# | |
limit_req zone=one burst=100; | |
location /nginx_status { | |
stub_status on; | |
access_log off; | |
} | |
location /stats { | |
root /srv/www/htdocs; | |
index index.html index.htm; | |
access_log off; | |
} | |
location / { | |
access_log /var/log/nginx/osgrid_sras2_prod.access.log main; | |
error_log /var/log/nginx/osgrid_sras2_prod.error.log error; | |
# | |
# send asset creation to sras2 on new box. | |
# | |
if ($request_method = POST) { | |
proxy_pass http://osgrid_sras2_prod; | |
break; | |
} | |
# | |
# send everything else to whichever sras instance has the | |
# asset. if it 404's, try the next one. | |
# | |
proxy_next_upstream http_404; | |
proxy_pass http://osgrid_sras_mix; | |
# | |
# cache asset data. | |
# | |
proxy_cache assets; | |
proxy_cache_valid 200 302 24h; | |
proxy_cache_valid 404 1m; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment