0

I'm trying to setup nginx webserver with Passenger support for Ruby on Rails application on Ubuntu 10.04 (on sub URI). All went fine until I tried to access the server/application from the browser.

My instalation of nginx is in location /opt/nginx

# my nginx.conf

server {
    listen       80;
    server_name  www.mydomain.com;
    root /websites/site/public;
    passenger_enabled on;
    passenger_base_uri /site; 


    location / {        # added by default, I don't know if its supposed to be here or not
        root   html;
        index  index.html index.htm;
    }

Then I started the server. But when I put www.mydomain.com/site in browser I get 404 Not Found error. Error.log shows this:

2011/03/04 10:07:07 [error] 21387#0: *2 open() "/opt/nginx/html/favicon.ico" failed (2: No such file or directory), client: 90.182.7.150, server: www.mydomain.com, request: "GET /favicon.ico HTTP/1.1", host: "80.79.23.71", referrer: "http://80.79.23.71/"
2011/03/04 10:07:07 [error] 21387#0: *2 open() "/opt/nginx/html/404.html" failed (2: No such file or directory), client: 90.182.7.150, server: www.mydomain.com, request: "GET /favicon.ico HTTP/1.1", host: "80.79.23.71", referrer: "http://80.79.23.71/"
2011/03/04 10:07:11 [error] 21387#0: *4 open() "/opt/nginx/html/favicon.ico" failed (2: No such file or directory), client: 90.182.7.150, server: www.mydomain.com, request: "GET /favicon.ico HTTP/1.1", host: "80.79.23.71:80", referrer: "http://80.79.23.71:80/"
2011/03/04 10:07:11 [error] 21387#0: *4 open() "/opt/nginx/html/404.html" failed (2: No such file or directory), client: 90.182.7.150, server: www.mydomain.com, request: "GET /favicon.ico HTTP/1.1", host: "80.79.23.71:80", referrer: "http://80.79.23.71:80/"
2011/03/04 10:07:13 [error] 21387#0: *5 open() "/opt/nginx/html/site" failed (2: No such file or directory), client: 90.182.7.150, server: www.mydomain.com, request: "GET /site HTTP/1.1", host: "80.79.23.71:80"
2011/03/04 10:07:13 [error] 21387#0: *5 open() "/opt/nginx/html/404.html" failed (2: No such file or directory), client: 90.182.7.150, server: www.mydomain.com, request: "GET /site HTTP/1.1", host: "80.79.23.71:80"
2011/03/04 10:07:15 [error] 21387#0: *6 open() "/opt/nginx/html/site" failed (2: No such file or directory), client: 90.182.7.150, server: www.mydomain.com, request: "GET /site HTTP/1.1", host: "80.79.23.71:80"
2011/03/04 10:07:15 [error] 21387#0: *6 open() "/opt/nginx/html/404.html" failed (2: No such file or directory), client: 90.182.7.150, server: www.mydomain.com, request: "GET /site HTTP/1.1", host: "80.79.23.71:80"
2011/03/04 10:07:19 [error] 21387#0: *7 open() "/opt/nginx/html/site" failed (2: No such file or directory), client: 90.182.7.150, server: www.mydomain.com, request: "GET /site HTTP/1.1", host: "80.79.23.71:80"
2011/03/04 10:07:19 [error] 21387#0: *7 open() "/opt/nginx/html/404.html" failed (2: No such file or directory), client: 90.182.7.150, server: www.mydomain.com, request: "GET /site HTTP/1.1", host: "80.79.23.71:80"

Why does nginx look for site in /opt/nginx/html/site as log shows when there's another path set in nginx.conf? Any idea whats wrong with my setup?

Kreeki
  • 103
  • 4

1 Answers1

1

if you want it on a subfolder eg site, then you should symlink your rails app public folder to /opt/nginx/html/site with the following command:

ln -s /websites/site/public /opt/nginx/html/site
anthonysomerset
  • 4,233
  • 2
  • 21
  • 24
  • Looks better but now I get `403 Forbidden` with `2011/03/04 11:25:05 [error] 21387#0: *17 directory index of "/opt/nginx/html/site/" is forbidden, client: 90.182.7.150, server: www.mydomain.com, request: "GET /site/ HTTP/1.1", host: "80.79.23.71"` in log. Would it be helpful if I uncomment `user root` in nginx.conf for nginx to run as root? – Kreeki Mar 04 '11 at 11:29
  • the error is saying directory indexing is forbidden, have you restarted apache to restart the rails app – anthonysomerset Mar 04 '11 at 11:33
  • Well, I finally managed to get it working. Thanks for everything. – Kreeki Mar 04 '11 at 14:19