0
votes

I'm using the following configuration:

  • Ubuntu 12.04 desktop i386
  • Ruby 1.9.3p327
  • Rails 3.2.9
  • NodeJS 0.8.14
  • Nginx + Phusion Passenger

I followed these steps:

  1. Crate a new Ubuntu virtual machine to test with
  2. Install Ruby + Rails + NodeJS
  3. Install Passenger + Nginx from here
  4. Create a new Rails app in /home/gerald/myapp without ActiveRecord (to discard DB issues)
  5. Run the said Rails app in dev mode (Rails server)

It worked perfectly, I was even able to see the rails.png image.

The problem is...

...When I configured Nginx to run the said app, I got a 404 error in the rails.png image.

These are the lines I added to /opt/nginx/conf/nginx.conf file:

http {
    ...
    server {
        listen 80;
        server_name www.mydomain.com;
        root /home/gerald/myapp/public;
        passenger_enabled on;
    }
    ...
}

The Nginx error.log only says:

2012/11/19 15:07:06 [error] 17398#0: *1 open() "/home/gerald/myapp/public/assets/rails.png" failed (2: No such file or directory), client: 127.0.0.1, server: localhost, request: "GET /assets/rails.png HTTP/1.1", host: "127.0.0.1", referrer: "http://127.0.0.1/"

Thank you in advance.

1

1 Answers

2
votes

The rails.png file is a asset, it's in asset pipeline, you should configure your nginx vhost.

It's something like:

location ~* ^/assets/ {
# 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;
}

Check this: link