Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

directory index of "/home/app/webapp/public/" is forbidden #137

Closed
alexlenail opened this issue May 6, 2016 · 10 comments
Closed

directory index of "/home/app/webapp/public/" is forbidden #137

alexlenail opened this issue May 6, 2016 · 10 comments

Comments

@alexlenail
Copy link

alexlenail commented May 6, 2016

I've been trying to use this project to set up a Flask app. Dockerfile:

FROM phusion/passenger-customizable

# Set correct environment variables.
ENV HOME /root

# Use baseimage-docker's init process.
CMD ["/sbin/my_init"]

# Expose Nginx HTTP service
EXPOSE 80

RUN /pd_build/utilities.sh
RUN /pd_build/python.sh

# Start Nginx / Passenger
RUN rm -f /etc/service/nginx/down

# Remove the default site
RUN rm /etc/nginx/sites-enabled/default

# Dockerfile:
ADD webapp.conf /etc/nginx/sites-enabled/webapp.conf
RUN mkdir /home/app/webapp
ADD . /home/app/webapp
# RUN chown -R app:app /home/app/webapp

ADD secret_key.conf /etc/nginx/main.d/secret_key.conf
ADD gzip_max.conf /etc/nginx/conf.d/gzip_max.conf

# Enable the Redis service.
RUN /pd_build/redis.sh
RUN rm -f /etc/service/redis/down

# Install relevant packages
RUN apt-get install -y python2.7-dev python-pip
RUN pip install uwsgi flask redis

# Clean up APT when done.
RUN apt-get clean && rm -rf /var/lib/apt/lists/* /tmp/* /var/tmp/*

webapp.conf:

server {
    listen 80;
    server_name server.dev;
    root /home/app/webapp/public;
    index index.html
    passenger_enabled on;
    passenger_user app;
}

I get the error message

directory index of "/home/app/webapp/public/" is forbidden, client: 192.168.99.1, server: server.dev, request: "GET / HTTP/1.1", host: "192.168.99.100"

I think I've followed the instructions quite carefully, so I'm not sure where this mistake is coming from. Some online posts suggest adding:

    location /home/app/webapp {
        autoindex on;
    }

But that doesn't seem to help. Let me know if I'm obviously missing something. Thanks @FooBarWidget !

@OnixGH
Copy link
Contributor

OnixGH commented May 6, 2016

Passenger expects passenger_wsgi.py. If the app is in a different file check out passenger_app_type and passenger_startup_file.

@alexlenail
Copy link
Author

alexlenail commented May 6, 2016

Thanks for getting back to me @OnixGH
I have a passenger_wsgi.py file. One thing that confuses me is that the quickstart guide, under fundamental concepts, says

GUnicorn and uWSGI are alternative application servers. Passenger replaces GUnicorn and uWSGI.

So why do you need uWSGI?

I see in the passenger deploy documentation that the root should be:

    root /var/www/myapp/code/public;

Is there any specific reason it must be in /var/www or would root /home/app/webapp/public be okay?

@alexlenail
Copy link
Author

@OnixGH @FooBarWidget
It seems like this person had a similar issue, but it seems like it would be specific to rails. What's going on here? My nginx configuration is basically identical to the one described in the readme and this still doesn't work.

@OnixGH
Copy link
Contributor

OnixGH commented May 7, 2016

The most common cause for this issue is that either Passenger doesn't recognize your app and thus cannot serve it (for which the root, passenger_app_type and passenger_startup_file matter), or that Passenger isn't actually started properly.

Did you also check that Passenger is running (passenger-status)? If not, something went wrong in the previous step(s) of the tutorial you referenced.

root can be anything, as long as your app is in path/to/approot and the root points to path/to/approot/public. I don't know what you mean by "why do you need uWSGI", Passenger uses the WSGI protocol to interact with the app, but that doesn't have anything to do with the uWSGI server.

@howdoicomputer
Copy link

I'm having the same problem, except it's for Rails. Most of the fixes or workarounds I've seen for Passenger are two or three years old.

I've followed the documentation exactly.

@AntonAL
Copy link

AntonAL commented Mar 17, 2017

I'm having the same problem, trying to deploy a Rails app with Nginx and Passenger.
No solution found yet.

@AntonAL
Copy link

AntonAL commented Mar 17, 2017

Found a solution
You need to explicitly specify, where actual Ruby code of a Rails application is located, using passenger_app_root directive.

Without this directive, Passenger will thinck, that actual Ruby code is located in path, specified with root nginx-directive.

Example of a correct configuration file '/etc/nginx/sites-available/app_name':

server {
  listen 80;

  server_name 188.225.35.216;
  passenger_enabled on;
  rails_env    production;
  root         /path/to/your/app/public/folder;
  passenger_app_root /path/to/your/app/code; # <<< Point Passenger to application code

  # redirect server error pages to the static page /50x.html
  error_page   500 502 503 504  /50x.html;
  location = /50x.html {
    root   html;
  }
}

In my case, Passenger was't serving my Rails app, that was deployed with Capistrano.
I had have to specify a value for passenger_app_root like following /var/www/my_app/current.

This will point Passenger exactly, where application code is presented.

@howdoicomputer
Copy link

I came across the same fix after I found someone's example configuration on a Google Groups forum post. passenger_app_root just... isn't well documented.

I just couldn't get my Rails application working with this image. I spent several days banging my head against the wall trying to get it to work. In the end, I ditched this container image and Phusion Passenger and wrote my own and I'm much, much, much happier.

@CamJN
Copy link
Contributor

CamJN commented May 16, 2017

Yes, Passenger assumes that the application code will be in the parent directory of the root dir, and provides the passenger_app_root (https://www.phusionpassenger.com/library/config/nginx/reference/#passenger_app_root) config to override this when that is not the case.

@OnixGH
Copy link
Contributor

OnixGH commented Jun 15, 2017

Closing as not related to passenger-docker. Questions about Passenger configuration can be posted to the Passenger community support forum.

@OnixGH OnixGH closed this as completed Jun 15, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants