2012-05-02 15 views
6

Stackoverflowers私はRailsのnginx設定に問題があります。私はRails 3.0.12アプリを走らせています。そして、私はnginxの新機能です。nginxはRails 3の静的資産を提供しません。

静的資産を提供するためにnginxを取得できないようです。 /publicフォルダ内のすべての要求に対して、私は404を取得します。私はこれまでに得たnginx設定を投稿しています。

user rails; 
worker_processes 1; 
daemon off; 

error_log /var/log/nginx/error.log; 
pid  /var/run/nginx.pid; 

events { 
    worker_connections 2048; 
} 

http { 
    include  /etc/nginx/mime.types; 
    default_type application/octet-stream; 

    access_log /var/log/nginx/access.log; 

    sendfile on; 
    tcp_nopush on; 
    tcp_nodelay on; 

    keepalive_timeout 65; 

    gzip on; 
    gzip_http_version 1.0; 
    gzip_comp_level 2; 
    gzip_proxied any; 
    gzip_types text/plain text/html text/css application/x-javascript text/xml application/xml application/xml+rss text/javascript; 

    server_names_hash_bucket_size 64; 

    include /etc/nginx/conf.d/*.conf; 
    include /etc/nginx/sites-enabled/*; 
} 

sites-enabled/project.conf:たぶん私は何か

nginx.confを逃した

upstream project { 
    # fail_timeout=0 means we always retry an upstream even if it failed 
    # to return a good HTTP response (in case the Unicorn master nukes a 
    # single worker for timing out). 

    # for UNIX domain socket setups: 
    server unix:/tmp/project.socket fail_timeout=0; 
} 

server { 
    listen 80; 
    root /srv/www/project/current/public; 
    passenger_enabled on; 
    server_name dev.project.eu; 
    server_name *.dev.project.eu; 

    location/{ 
     #all requests are sent to the UNIX socket 
     proxy_pass http://project; 
     proxy_redirect  off; 

     proxy_set_header Host    $host; 
     proxy_set_header X-Real-IP  $remote_addr; 
     proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; 

     client_max_body_size  10m; 
     client_body_buffer_size 128k; 

     proxy_connect_timeout  90; 
     proxy_send_timeout   90; 
     proxy_read_timeout   90; 

     proxy_buffer_size   4k; 
     proxy_buffers    4 32k; 
     proxy_busy_buffers_size 64k; 
     proxy_temp_file_write_size 64k; 
     root /srv/wwww/project/current/public; 
    } 

} 

私はproject.confからlocation /ブロックを削除しようとしましたが、それは何もしなかった、資産はまだありません可視。

私はまたserve_static_assetsのRailsを認識していますが、そうする必要がありますので、nginxにこれらのアセットを提供してもらいたいと思います。

答えて

6

あなたはそのような何か(documentation on locations)を追加する必要があります。

location/{ 
    try_files $uri @ruby; 
} 

location @ruby { 
    proxy_pass http://project; 
} 
0

私はこのスレッドが一年以上古いです知っているが、私は生産

にそれがうまく作られたものを実行している同じ問題を抱えていました私のために開発中の

rake assets:precompile 

を実行している、と

のコメントを解除しました。 210
load 'deploy/assets' 

レールを使用していますが、

関連する問題