diff README.md @ 322:2235aa625af0

Add memcached and nginx config to readme.
author edogawaconan <me@myconan.net>
date Sun, 06 Apr 2014 03:42:02 +0900
parents d6e94d7d0325
children a0166874e31e
line wrap: on
line diff
--- 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
 ----