在 public 目录下放置文件 logo.png 或者建立文件夹 images/logo.png, 本地可以直接访问http://localhost:3002/logo.png ,但是服务器 production 下是 404 (The page you were looking for doesn't exist.). 然后,assets/application.js 可以直接在本地访问,但是服务器端 403 forbidden。 查了一些解决方案,貌似应该是文件权限问题,但是 asset 整个文件夹(production 下在public/assets)给了 755 权限,还是同样的错误。 求帮助!
ps: nginx 配置
upstream unicorn { server unix:/tmp/unicorn.haizheba.sock fail_timeout=0; }
server {
listen 80;
server_name haizheba.com;
root /home/william/apps/haizheba/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;
}
error_page 500 502 503 504 /500.html;
client_max_body_size 4G;
keepalive_timeout 10;
}