Skip to content

Instantly share code, notes, and snippets.

@PatrickTulskie
Created July 27, 2011 16:56
Show Gist options
  • Save PatrickTulskie/1109822 to your computer and use it in GitHub Desktop.
Save PatrickTulskie/1109822 to your computer and use it in GitHub Desktop.
nginx, unicorn, memcached
server {
error_log /usr/local/var/log/nginx/error.log;
listen widgets.local:80;
server_name widgets.local;
client_max_body_size 4G;
keepalive_timeout 70;
root /Users/username/rails/widgets/public;
error_page 502 /502.html;
error_page 504 /504.html;
error_page 404 /404.html;
error_page 500 503 /500.html;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_intercept_errors on;
proxy_redirect off;
proxy_buffering on;
location / {
if ($request_method != GET) {
proxy_pass http://widgets_com;
break;
}
try_files $uri /cache/$uri/index.html /cache/$uri.html /cache/$uri @widgets_cache;
}
location @widgets_cache {
internal;
default_type text/html;
add_header "Content" "text/html; charset=utf8";
charset utf-8;
set $memcached_key PageCache:$uri;
memcached_pass memcache_servers;
proxy_intercept_errors on;
error_page 404 502 504 = @widgets_app;
break;
}
location @widgets_app {
internal;
proxy_pass http://widgets_com;
break;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment