NginxとUnicornを使用してRails3.1アプリを本番環境で実行しています。そして、何らかの理由で、カスタム404および500htmlエラーページが表示されません。代わりに、実際のエラーメッセージ(「ルーティングエラー」など)が表示されます。
私のproduction.rbファイルには、config.consider_all_requests_local = false
そして、ほぼ同じ構成の同じサーバー上に、正常に機能する「ステージング」サイトがあります。私が知る限り、唯一の違いは、本番環境にはSSLがあり、ステージングにはSSLがないことです。
本番アプリのNginx構成は次のとおりです。
upstream unicorn_myapp_prod {
server unix:/tmp/unicorn.myapp_prod.sock fail_timeout=0;
}
server {
listen 80;
server_name myapp.com;
root /home/deployer/apps/myapp_prod/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn_myapp_prod;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
server {
listen 443 default;
ssl on;
ssl_certificate /home/deployer/apps/myapp_prod/shared/ssl_certs/myapp_prod.crt;
ssl_certificate_key /home/deployer/apps/myapp_prod/shared/ssl_certs/myapp_prod.key;
server_name myapp.com;
root /home/deployer/apps/myapp_prod/current/public;
location ^~ /assets/ {
gzip_static on;
expires max;
add_header Cache-Control public;
}
try_files $uri/index.html $uri @unicorn;
location @unicorn {
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_pass http://unicorn_myapp_prod;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}
何か案は?ありがとう!