403 Forbidden on Rails app w/ Nginx, Passenger

nginx passenger directory index of is forbidden
nginx 403 forbidden
rails 403
http/1.1 403 forbidden
laravel 403 forbidden nginx
nginx/passenger rails
nginx 403 forbidden centos
nginx 403 forbidden php

First off, apologies: I know the 403 Forbidden question is a common one for Rails/Nginx installs, but none of the answers I've read so far have solved it for me.

Disclaimer: This is my first time deploying a Rails app somewhere that isn't Heroku. Please be gentle. ;)

Situation: I have a Rails app running on an Ubuntu 12.04 server, running Nginx (installed with Passenger).

I've deployed my app to my server correctly, but when I attempt to access the site, I receive a 403 Forbidden error.

Checking my error logs, I see:

2013/10/23 22:47:01 [error] 27954#0: *105 directory index of "/var/www/colepeters.com/current/public/" is forbidden, client: 50.3…server: colepeters.com, request: "GET / HTTP/1.1", host: "colepeters.com"
2013/10/23 22:47:10 [error] 27954#0: *106 directory index of "/var/www/colepeters.com/current/public/" is forbidden, client: 184…server: colepeters.com, request: "GET / HTTP/1.1", host: "colepeters.com"
2013/10/23 22:47:12 [error] 27954#0: *107 directory index of "/var/www/colepeters.com/current/public/" is forbidden, client: 151…server: colepeters.com, request: "GET / HTTP/1.1", host: "colepeters.com"

However, when checking permissions on this directory, I see that the user I have setup to use Nginx had both read and execute permissions on it.

Here's the relevant info from my nginx.conf:

user  XXXX;
worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    passenger_root /home/cole/.rvm/gems/ruby-2.0.0-p247/gems/passenger-4.0.21;
    passenger_ruby /home/cole/.rvm/wrappers/ruby-2.0.0-p247/ruby;

    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

    server {
       listen       80;
        server_name  colepeters.com www.colepeters.com;
        passenger_enabled on;
        root /var/www/colepeters.com/current/public/;
        rails_env production;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
          root   /var/www/colepeters.com/current/public;
          index  index.html index.htm;
          # autoindex on;
        }

I would greatly appreciate any help on resolving this. Thanks!

UPDATE I have since corrected the erroneus passenger_ruby path, but the 403 Forbidden is persisting, even after restarting Nginx.


You can check the path of your passenger installation with

passenger-config --root

and the path of your ruby installation with

which ruby

then compare with the inserted in nginx.conf.

How do I resolve 403 Forbidden for nginx + passenger + rails + , Once I was done with this tutorial, I attempted to hit my sample application with a browser and got the 403 error. When I checked the error log I  I'm trying to get an Ruby on Rails application running with passenger and nginx but I'm getting 403 forbidden when I'm Stack Exchange Network Stack Exchange network consists of 177 Q&A communities including Stack Overflow , the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.


I got the same error. In my case, I fixed it by removing the location / {} entry. - or make sure that your user have permission to your rails project

...
server {
    listen       80;
    server_name  127.0.0.1;
    passenger_enabled on;
    rails_env production;
    root /www/kalender/public ;

    #charset koi8-r;

    access_log  /var/log/nginx/host.access.log;

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

How to fix 403 Fobidden issue on Nginx + Rails application, combination of Nginx + Passenger or Nginx + Unicorn. And one of the most common issues I see when installing and configuring Nginx is 403 Forbidden error  I am not sure if app specific gem sets are being used, there is only on rails app and the gems were all installed in that apps directory. I also am not sure about rvm, is there a way to check that? We used passenger-intall-nginx-module for nginx. I used gem install passenger to install passenger. RVM 1.2.5, nginx 1.4.4, passenger 4.0.41


Adding passenger_enabled on; to the server directive worked for me.

Ruby on Rails - Passenger Nginx - 403 Forbidden, If you server is running Nginx+Passeneger , you can start your Ruby application in the following way: cd /home/user/rails_apps/user; sudo -u user  403 Forbidden on Rails app w/ Nginx, Passenger. Ask Question Asked 6 years, 5 months ago. Active 1 year, 2 months ago. 403 Forbidden on Rails app w/ Nginx


I was running a similar setup to yours and having the same problem with my nginx.conf file. Stumbling across the Nginx pitfalls page helped me solve it.

Your file looks similar to mine, so I'll share two things you may want to try that worked for me:

  1. first, you have the root path in both the server {} block AND the location {} block. While not necessarily a problem, according to the docs linked above "If you add a root to every location block then a location block that isn't matched will have no root." I got rid of the roots in the location blocks but kept it in the server block.

  2. move the 'index' directives (index index.html index.htm;) out of the location block up to within the http {} block. The location blocks will inherit from this.

doing those two things and restarting the server worked for me.

403 Forbidden response on a ubuntu + nginx + passenger server , I'm trying to deploy my Rails app on my Digital Ocean VPS but I'm getting a 403 when I visit the IP adres. This is the output of my errorlog: [ 2014-11-02 04:18:  Hello all, I am trying to set up a production server and am having a little bit of trouble. I am hoping someone can help me. I am new to Nginx. I usually use Apache for setting up my rails servers but decided I wanted some experience with Nginx.


The problem lies in the location / {...} section: the passenger_enabled on doesn't propagate from the server {...} into the location / {...}.

If you either remove location / {...}, or add passenger_enabled on to it, it should work.

403 Forbidden Error With Passenger, Phusion Passenger Standalone web server started PID file: It turns out that even though thee permissions on my rails app were fine, the base  403 Forbidden nginx/0.8.52 It turns out that even though thee permissions on my rails app were fine, the base directory did not allow proper access: root:/# ls -l . . . drwx------ 9 root root 4096 Nov 21 11:48 opt . . .


403 Forbidden with rails, nginx, and passenger : rails, if you're using app-specific gemset, then passenger_ruby should look like /usr/​local/rvm/gems/ruby-2.1.0@dashboard/wrappers/ruby. inside server block, root must  403 Forbidden on Rails app w/ Nginx, Passenger (5) Adding passenger_enabled on; to the server directive worked for me. First off, apologies: I know the 403 Forbidden question is a common one for Rails/Nginx installs, but none of the answers I've read so far have solved it for me.


directory index of "/home/app/webapp/public/" is forbidden · Issue , Dockerfile: FROM phusion/passenger-customizable # Set correct I'm having the same problem, trying to deploy a Rails app with Nginx and  So nginx complains about the index missing. I've watched the first minutes of the video you've posted and Ι saw that the index page is dynamically generated by the rails app. So you need to either install, or setup correctly you app, in order to get the index page.


Getting a 403 on Ubuntu + Nginx, My error log outputs the following, [ 2014-11-02 04:18:12.0511 if it doesn't find the file, Nginx will hand it off to Passenger to try the Rails app. If the client receives an error code such as 403 (Forbidden) or 405 (Method Not Allowed) then it shouldn't send the request's body.