Skip to content

Instantly share code, notes, and snippets.

@igaiga
Created December 29, 2013 06:45
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save igaiga/8168084 to your computer and use it in GitHub Desktop.
Save igaiga/8168084 to your computer and use it in GitHub Desktop.
upstream tdiary.unicorn {
server localhost:8080;
}
server {
server_name igarashikuniaki.net;
access_log /var/log/nginx/localhost.access.log;
location / {
root /var/www/;
index index.html index.htm;
}
location = / {
rewrite ^ /diary/ redirect;
}
location = /diary {
rewrite ^ /diary/ redirect;
}
location = /tdiary {
rewrite ^ /diary/ redirect;
}
location ~ ^/tdiary {
rewrite ^/tdiary/(.*)$ /diary/$1 redirect;
}
location ~ ^/[0-9\-]+\.html$ {
rewrite ^ /diary$request_uri redirect;
}
location ~ ^/diary/ {
try_files $uri @unicorn;
}
location @unicorn {
rewrite /diary/([0-9\-]+)\.html$ /diary/index.rb?date=$1 last;
proxy_pass http://tdiary.unicorn;
}
}
server {
server_name www.igarashikuniaki.net;
rewrite ^ $scheme://igarashikuniaki.net$request_uri redirect;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment