# HG changeset patch # User edogawaconan # Date 1396723322 -32400 # Node ID 2235aa625af058a44a69470b82a4fe6f9431f099 # Parent fec39456dcbe7f286155f031b9d7917d531a0158 Add memcached and nginx config to readme. diff -r fec39456dcbe -r 2235aa625af0 README.md --- a/README.md Sun Apr 06 03:20:10 2014 +0900 +++ b/README.md Sun Apr 06 03:42:02 2014 +0900 @@ -18,6 +18,7 @@ Optional: * Newrelic account +* memcached Suggested: @@ -28,6 +29,45 @@ Left as an exercise. +nginx configuration +------------------- + +Here's nginx configuration snippet which use memcached to completely bypass Rails. + + server { + server_name 0paste.com; + listen 80; listen [::]:80; + root /var/www/0paste.com/public; + error_page 445 = @zp; + error_page 404 /404.html; + + if ($request_method = POST) { + return 445; + } + + location / { + expires max; + try_files $uri @zp; + } + + location ~ /(\d+(?:-\x+)?)(?:(\.txt)|\.html)?$ { + expires max; + charset utf-8; + set $memcached_key "zeropaste:pastes:$1$2"; + memcached_pass localhost:11211; + + default_type text/html; + error_page 404 502 = @zp; + } + + location @zp { + proxy_pass http://localhost:9200; + proxy_set_header X-Forwarded-For $remote_addr; + proxy_set_header Host $host; + proxy_intercept_errors on; + } + } + Misc ----