铁路3.1 favicon.ico不提供
-
26-10-2019 - |
题
尽管在 /public
目录,如果我访问 http://site.example.com/favicon.ico
我得到了404页。有趣的是,如果我试图参观 http://site.example.com/500.html
我也让404页让我相信 /public
文件根本没有提供。我正在用独角兽运行Nginx。是否有任何轨道上的设置可以禁用 /public
资产?
编辑我的nginx配置:
server {
listen 80;
client_max_body_size 4G;
server_name _;
keepalive_timeout 5;
# Location of our static files
location ~ ^/(assets)/ {
root /srv/ctr/current/public;
gzip_static on; # to serve pre-gzipped version
expires max;
add_header Cache-Control public;
}
location / {
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $http_host;
proxy_redirect off;
# If you don't find the filename in the static files
# Then request it from the unicorn server
if (!-f $request_filename) {
proxy_pass http://app_server;
break;
}
}
# error_page 500 502 503 504 /500.html;
# location = /500.html {
# root /var/rails/testapp/public;
# }
}
我有 root :to => 'reports#index'
在我的路线中,但我看不出这怎么可能有所作为。
解决方案我移动了线 root /srv/ctr/current/public;
上面 keepalive_timeout 5;
解决方案
检查您的路由。rb以确保您没有这样的行
root :to => "home#index"
还要检查nginx.conf以确保您有
root /path/to/app/public;
对于您的服务器 / VHOST。
戴夫
其他提示
配置您的nginx .conf
vim /etc/nginx/conf.d/your_project.conf
server {
......
# static resource routing - both assets folder and favicon.ico
location ~* ^/assets/|favicon.ico {
# Per RFC2616 - 1 year maximum expiry
# http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html
expires 1y;
add_header Cache-Control public;
# Some browsers still send conditional-GET requests if there's a
# Last-Modified header or an ETag header even if they haven't
# reached the expiry date sent in the Expires header.
add_header Last-Modified "";
add_header ETag "";
break;
}
}
不隶属于 StackOverflow