Rotaie 3.1 favicon.ico non essere servito
-
26-10-2019 - |
Domanda
Nonostante sia nella directory /public
, se visito http://site.example.com/favicon.ico
ottengo pagina 404. È interessante notare che, se provo a visita http://site.example.com/500.html
Ho anche pagina 404 mi porta a credere che i file /public
non vengono serviti fino a tutti. Sono in esecuzione Nginx con Unicorn. Ci sono delle impostazioni in Rails che avrebbe disattivare la porzione di beni /public
?
Modifica La mia nginx config:
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;
# }
}
Io ho root :to => 'reports#index'
nei miei percorsi, ma io non vedo come questo potrebbe fare la differenza.
Soluzione
Ho spostato la linea di root /srv/ctr/current/public;
sopra keepalive_timeout 5;
Soluzione
Controlla il tuo routes.rb per assicurarsi che non si dispone di una linea come
root :to => "home#index"
Inoltre controllare nginx.conf per essere sicuri di avere
root /path/to/app/public;
per il server / vhost.
Dave
Altri suggerimenti
??Rails, non Favicon.ico trovato
Configura il tuo 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;
}
}