Skip to content

Instantly share code, notes, and snippets.

@alaz
Forked from johnthethird/nginx.conf
Created March 6, 2010 15:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save alaz/323751 to your computer and use it in GitHub Desktop.
Save alaz/323751 to your computer and use it in GitHub Desktop.
Edits and comments to the Nginx config for Riak
# Config for Nginx to act as a front-end for Riak
# The main goal is to proxy all GETs directly to Riak, and disallow anything else (POST, PUT, etc)
# Also, disallow use of the map/reduce query links (i.e. /riak/bucket/key/_,_,_)
# Config is in /etc/nginx/sites-available/default or somewhere like that
# Set up load-balancing to send requests to all nodes in the Riak cluster
# Replace these IPs/ports with the locations of your Riak nodes
upstream riak_hosts {
server 127.0.0.1:8098;
#server 10.0.1.18:8098;
#server 10.0.1.19:8098;
}
server {
listen 80;
server_name _;
access_log /var/log/nginx/riak.access.log;
# your standard Nginx config for your site here...
location / {
root /var/www/nginx-default;
}
# Expose the /riak endpoint and allow queries for keys only
location /riak/ {
proxy_set_header Host $host;
proxy_redirect off;
## Why setting these buffers so large? It's for the client's data, i.e. POSTs
#client_max_body_size 10m;
#client_body_buffer_size 128k;
## As far as I understand riak uses large headers, so it's better to set large
## buffer for the client headers
client_header_buffer_size 64k;
## Note that Nginx will be choosing another upstream using these timeouts...
## these are pretty large.
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
## "proxy_buffer" is equal to 1 buffer from "proxy_buffers" -> no need to set it
# proxy_buffer_size 64k; # If the buffers are set to small, nginx will complain about "too large headers"
proxy_buffers 4 64k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
limit_except GET {
deny all;
}
proxy_pass http://riak_hosts;
}
## Instead of "if" (NB: Igor Sysoev blames use of "if")
location ~ "^/riak/[^/]*/[^/]*/[^,]+,[^,]+," {
deny all;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment