nginx + thin + Rails 3.2 セットアップがあります。現在、キャッシュされたページを直接提供できるようにnginxをセットアップしようとしています。
ただし、nginx は以下の nginx 構成ファイルで *.html リクエストを Rails に渡します。HTMLファイルはパブリックフォルダーに存在し、nginxはそれらを見つけますが、それらはまだRailsに渡されています。
upstream site {
server unix:/home/site/deploy/site/shared/pids/thin.0.sock;
}
server {
listen 80;
server_name www.example.com;
rewrite ^(/.*) http://example.com$1 permanent;
}
# asset server
server {
listen 80;
server_name assets.example.com;
expires max;
add_header Cache-Control public;
charset utf-8;
root /home/site/deploy/site/current/public/;
}
# frontend
server {
listen 80;
server_name .example.com;
charset utf-8;
root /home/site/deploy/site/current/public/;
index index.html;
location ~* ^.+.(jpg|jpeg|gif|png|swf|zip|rar|doc|xls|exe|pdf|ppt|txt|tar)$ {
root /home/site/deploy/site/current/public/;
expires max;
break;
}
# serve static files
if (-f $request_filename) {
break;
}
gzip on;
location / {
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
if (-f $request_filename) {
break;
}
if (-f $document_root/cache/$host/$uri/index.html) {
rewrite (.*) /cache/$host/$1/index.html break;
}
if (-f $document_root/cache/$host/$uri.html) {
rewrite (.*) /cache/$host/$1.html break;
}
if (-f $document_root/cache/$host/$uri) {
rewrite (.*) /cache/$host/$1 break;
}
proxy_pass http://site;
break;
}
}
私はnginxを初めて使用します。この構成ファイルは、私が取り組んでいない以前のプロジェクトからコピーされているため、これはおそらく非常に初心者の質問です.