Skip to content

Instantly share code, notes, and snippets.

@dysinger
Forked from johnthethird/nginx.conf
Created March 7, 2010 21:16
Show Gist options
  • Save dysinger/324633 to your computer and use it in GitHub Desktop.
Save dysinger/324633 to your computer and use it in GitHub Desktop.
# 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;
client_max_body_size 10m;
client_body_buffer_size 128k;
proxy_connect_timeout 90;
proxy_send_timeout 90;
proxy_read_timeout 90;
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;
if ($request_method != GET) {
return 405;
}
# Disallow any link with the map/reduce query format "bucket,tag,_"
if ($uri ~ "/riak/[^/]*/[^/]*/[^,]+,[^,]+," ) {
return 405;
}
if ($request_method = GET) {
proxy_pass http://riak_hosts;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment