2011-08-28 12 views
5

Ho creato un ambiente di produzione con Rails 3.1.0rc6, Thin e Nginx.Rails ignora config.action_dispatch.x_sendfile_header? Utilizzo di Thin + Nginx

Per qualche motivo, dopo aver impostato config.action_dispatch.x_sendfile_header = "X-Accel-Redirect" in config/environments/production.rb, Rails sembra averlo completamente ignorato; attività non sono serviti, e le intestazioni di risposta per un file è la seguente:

Server: nginx/1.0.5 
Date: Sun, 28 Aug 2011 00:26:08 GMT 
Content-Type: image/png 
Content-Length: 0 
Cache-Control: no-cache 
Last-Modified: Sat, 27 Aug 2011 23:47:35 GMT 
Etag: "af4810c52cb323d9ed061d1db5b4f296" 
X-UA-Compatible: IE=Edge,chrome=1 
X-Sendfile: /var/www/***/app/assets/images/bg-linen-light.png 
X-Runtime: 0.004595 
X-Content-Digest: da39a3ee5e6b4b0d3255bfef95601890afd80709 
Age: 0 
X-Rack-Cache: stale, valid, store 

200 OK 

così sembra Rails è ancora Impostazione dell'intestazione . Ho provato ad aggiungere la riga sendfile_header a config/application.rb, ma suppongo che venga ignorata o ignorata.

Il mio file yml per Thin:

--- 
chdir: /var/www/*** 
environment: production 
address: 0.0.0.0 
port: 3000 
timeout: 30 
log: log/thin.log 
pid: tmp/pids/thin.pid 
max_conns: 1024 
max_persistent_conns: 512 
require: [] 

wait: 30 
servers: 1 
daemonize: true 

Nginx vhost:

upstream *** { 
    server 127.0.0.1:3000; 
} 

server { 
    listen 80; 
    server_name ***; 
    root /var/www/***/public; 
    index index.html; 

    location/{ 
     proxy_set_header X-Real-IP $remote_addr; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 
     proxy_set_header Host $http_host; 
     proxy_redirect off; 

     if (-f $request_filename/index.html) { 
      rewrite (.*) $1/index.html break; 
     } 

     if (-f $request_filename.html) { 
      rewrite (.*) $1.html break; 
     } 

     if (!-f $request_filename) { 
      proxy_pass http://***; 
      break; 
     } 
    } 
} 

Ho già provato /etc/init.d/thin stop poi avviarlo di nuovo un paio di volte, senza alcun risultato.

risposta

3

mi sono imbattuto in questo production.log:

Started GET "/assets/bg-linen-light.png" for ***** at 2011-08-28 11:04:42 +0400 
Served asset /bg-linen-light.png - 304 Not Modified (102ms) 

Il problema è che il browser aveva chiesto che il file primax_sendfile_header è stato cambiato a quello che dovrebbe essere, così sembra che Rails (e/o il browser) non fa assolutamente nulla dopo aver cambiato la variabile.

Il problema è stato risolto andando a rails console e digitando Rails.cache.clear. Un duro aggiornamento dopo che risolve il problema!

Started GET "/assets/bg-linen-light.png" for ***** at 2011-08-28 11:06:06 +0400 
Served asset /bg-linen-light.png - 200 OK (4ms) 
Problemi correlati