2012-05-02 5 views
6

स्टैक ओवरफ्लॉवर। मुझे अपने रेल nginx विन्यास के साथ एक समस्या है। मैं एक रेल 3.0.12 ऐप चला रहा हूं, और मैं nginx के लिए काफी नया हूँ।nginx रेल 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 स्विच के बारे में भी पता है, लेकिन मुझे nginx उन संपत्तियों की सेवा करना होगा, जैसा कि ऐसा करना चाहिए।

उत्तर

6

आप ऐसा ही कुछ (documentation on locations) जोड़ने की जरूरत:

location/{ 
    try_files $uri @ruby; 
} 

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

मैं जानता हूँ कि इस सूत्र एक वर्ष से अधिक पुराना है, लेकिन मैं उत्पादन में

बात यह है कि यह काम किया जाता चल ही समस्या थी के लिए मुझे विकास में

rake assets:precompile 

चल रहा था, और uncommenting

load 'deploy/assets' 

रेल भले ही मैं उपयोग कर रहा हूँ 4.

संबंधित मुद्दे