Skip to content

Instantly share code, notes, and snippets.

@bdossantos
Created December 14, 2012 14:50
Show Gist options
  • Select an option

  • Save bdossantos/4285967 to your computer and use it in GitHub Desktop.

Select an option

Save bdossantos/4285967 to your computer and use it in GitHub Desktop.
Nginx lb + CouchDB
# client body
client_header_timeout 3600;
client_body_timeout 3600;
client_max_body_size 128m;
# proxy options
proxy_read_timeout 3600;
proxy_connect_timeout 3600;
#ignore_invalid_headers on;
send_timeout 3600;
# req rate limitation
#limit_req_zone $binary_remote_addr zone=one:100m rate=5r/s;
upstream couchdb_cluster {
server couchdb01;
server couchdb02;
}
server {
listen 127.0.0.1:8080;
server_name lb;
root /usr/share/nginx/www;
index index.html index.htm;
#access_log /var/log/nginx/access_db-lb.optin-machine.com.log;
# basic couch db routing
location / {
# allows a user no more than 5 request per second on average, with
# bursts of no more than 10 queries.
#limit_req zone=one burst=10;
try_files $uri $uri/ @couchdb;
allow 127.0.0.1;
deny all;
}
location @couchdb {
proxy_pass http://couchdb_cluster;
proxy_redirect off;
proxy_buffering off; # don't break continuous _changes
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
if ($request_method ~ ^(DELETE)$ ) {
return 444;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment