bricker
bricker

Reputation: 8941

Passenger/nginx not loading Sinatra app

I'm trying to run a few Sinatra apps under sub-uri's, but it seems that Passenger isn't picking them up as Rack applications.

From the nginx-error log: 403 error, directory index of "/web/archive/sites/archive/app1/" is forbidden. If I place index.html in that directory, that HTML file renders.

The apps run fine with rackup on my local machine, so I feel the application code is irrelevant. I have also SSH'd in as both the nginx user (user nginx at the top of the nginx config), and as the archive user, which is the user used to deploy all of these applications, and which owns all of the directories and files. I have no problem navigating to any of these files with either user.

Also, this setup works fine if I move it over to a subdomain, like archive.domain.com, and then have the app symlinks live right in /web/archive/sites (rather than /web/archive/sites/archive), and otherwise use pretty much the same nginx config, which is why I don't believe this is a permissions issue.

nginx config

server {
    listen 80;
    server_name domain.com;

    location /archive {
        root /web/archive/sites;
        passenger_enabled on;
        passenger_base_uri /app1;
        passenger_base_uri /app2
    }
}

directory structure

/web
  |
  +-- archive/
       |
       +-- sites/
       |    |
       |    +-- archive/
       |         |
       |         +-- app1 -> /web/archive/apps/app1/current/public
       |         |
       |         +-- app2 -> /web/archive/apps/app2/current/public 
       |
       +-- apps/
            |
            +-- app1/
            |    |
            |    +-- current/
            |    |
            |    +-- public/
            |    |
            |    +-- config.ru
            |
            +-- app2/
                 |
                 +-- (same as app1/)

Upvotes: 2

Views: 1215

Answers (1)

Florian Feldhaus
Florian Feldhaus

Reputation: 5932

The passenger_base_uri together with the root in your configuration example do not match with the directory structure (e.g /web/archive/sites/app1 vs /web/archive/sites/archive/app1). As far as I understand Passenger does not consider the location but only root and passenger_base_uri.

Try changing the configuration into

server {
    listen 80;
    server_name domain.com;

    location /archive {
        root /web/archive/sites/archive;
        passenger_enabled on;
        passenger_base_uri /app1;
        passenger_base_uri /app2
    }
}

Upvotes: 1

Related Questions