【发布时间】:2014-07-08 06:01:16
【问题描述】:
我有一个 rails 应用程序部署在 Amazon EC2 服务器 - Nginx & Unicorn
我必须启用浏览器缓存。
这是我的 nginx.conf
的代码upstream unicorn {
server unix:/tmp/unicorn.nqlive.sock fail_timeout=0;
}
server {
listen 80;
listen 443 ssl;
server_name xyz.com;
ssl_certificate /usr/local/nginx/conf/server.crt;
ssl_certificate_key /usr/local/nginx/conf/server.key;
root /home/ec2-user/hello/production/current/public;
location ~* \.(css|js|gif|jpe?g|png)$ {
expires 168h;
add_header Pragma public;
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;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 20M;
keepalive_timeout 10;
}
所有的css、图片、js都开始报403 Forbidden Error。我也尝试将权限更改为 777,但没有成功。
【问题讨论】:
-
你必须显示完整的配置。
-
他们在
/home/ec2-user/hello/production/current/public吗? -
好吧,检查error.log
标签: ruby-on-rails nginx amazon-ec2 browser-cache