简体   繁体   中英

directory index of "..." is forbidden

I am trying to get phusion passenger and nginx running on Mac OSX. It has been very difficult.

I followed the instructions here exactly.

$ brew install nginx --with-passenger
$ brew info nginx --with-passenger 

Then it tells me this:

To activate Phusion Passenger, add this to /usr/local/etc/nginx/nginx.conf, inside the 'http' context:
passenger_root /usr/local/opt/passenger/libexec/src/ruby_supportlib/phusion_passenger/locations.ini; passenger_ruby /usr/bin/ruby;

What's interesting about that is that is not the ruby my site uses. I use rvm and have generated a .versions.conf file:

rvm --create --versions-conf use ruby-2.1.2@core

Hence, when you cd to my root folder of site, you get the following:

$ rvm-prompt
ruby-2.1.2@core

So that is what I added to nginx.conf:

http {
  ...
  passenger_root /usr/local/opt/passenger/libexec/src/ruby_supportlib/phusion_passenger/locations.ini;
  passenger_ruby /Users/dviglione/.rvm/gems/ruby-2.1.2@core/wrappers/ruby;

Note that when I run passenger-config, it does give me a different location for locations.ini:

$ /usr/local/bin/passenger-config --root
/usr/local/Cellar/passenger/5.0.26/libexec/src/ruby_supportlib/phusion_passenger/locations.ini

I don't know which location is correct but I stuck with the one that it provided during the install. If I changed to the other location, I get a different issue: "This site can't be reached".

In nginx.conf, my server block looks like this:

server {
    rack_env development;
    listen       8080;
    server_name  mysite_development;
    root /Users/myuser/projects/core;
    access_log /Users/myuser/projects/core/log/nginx_access.log;
    error_log /Users/myuser/projects/core/log/nginx_error.log;
    passenger_enabled on;
}

I added the following to /etc/hosts:

 127.0.0.1       mysite_development
 255.255.255.255 broadcasthost
 ::1             localhost 
 fe80::1%lo0     localhost

The root directory has the following permissions:

$ ls -ld core
drwxr-xr-x  37 myuser  CORP\Domain Users  1258 Oct 14 18:45 core

Yet, when I navigate to http://mysite_development:8080/ , I get the following error in my nginx error log:

2016/10/14 18:52:23 [error] 90766#0: *1 directory index of "/Users/myuser/projects/core/" is forbidden, client: 127.0.0.1, server: mysite_development, request: "GET / HTTP/1.1", host: "mysite_development:8080"

The problem is not with nginx itself because I created a test folder and put an index.html in there and then created a server block for that and the index.html successfully displayed in browser. So problem is either with Passenger or Rails.

Note if I add this to the server block:

    location / {
        root   html;
        index  index.html index.htm;
    }

Then I just get the 'Welcome to nginx!' page.

I even chmod 777 recursively on the entire directory and its files of the Rails app. Still get the 403 Forbidden error. It has to be a problem with Passenger.

How can I resolve this?

You need to explicitly specify, where actual Ruby code of a Rails application is located, using passenger_app_root directive, described in Passenger's documentaion .

More details in my full answer .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM