nginx server shows 403 error: directory index of > “/home/deploy/my_app/current/public/” is forbidden

Everything was working fine earlier. I got message on Digital Ocean server and so upgraded a few packages on droplet (Ubuntu 18.04 LTS). Since then the site is broken and I get 403 error.

I have restarted nginx several times. Also reinstalled Rails application. I am a newbie. Any help to resolve this 403 error is greatly appreciated.

/etc/nginx/sites-available/default file is as follows:

server {
        listen 80;
        listen [::]:80;
        server_name *;
        return 301 https://$host$request_uri;
server {
        listen 443 ssl http2;
        server_name *;
        passenger_enabled on;
        rails_env    production;
        root         /home/deploy/my_app/current/public;
        ssl_certificate /home/deploy/letsencrypt/fullchain.pem;
        ssl_certificate_key /home/deploy/letsencrypt/privkey.pem;

        # redirect server error pages to the static page /50x.html


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Accepted Answer

The problem is resolved.

In file nginx.conf the following line needed uncommenting.

# Phusion Passenger config
# Uncomment it if you installed passenger or passenger-enterprise

include /etc/nginx/passenger.conf;

Site Moderator
Site Moderator badge
January 12, 2021

Hi @codecutter,

There are two things I would recommend. First, make sure you have the proper ownership and permissions on your document root folder /home/deploy/my_app/current/public and /home/deploy/my_app and /home/deploy/my_app/current/. Unless you have a specific permissions scheme, files should be 644 and folders 755. As to ownership, you need to see what your NGINX is using from it’s settings in /etc/nginx.

Once you verified this, I’ll recommend checking out the nginx error_log. In there it should say where exactly is this forbidden error coming from.

If you are not sure about the error from your logs, you can paste it here and I’ll assist in troubleshooting it.

Regards, KFSys

Using $nginx -V, I verified that the version got upgraded from 1.12.2 to 1.18.0 It was working in earlier version. I wonder if new version broke it.

Try DigitalOcean for free

Click below to sign up and get $200 of credit to try our products over 60 days!

Sign up

Get our biweekly newsletter

Sign up for Infrastructure as a Newsletter.

Hollie's Hub for Good

Working on improving health and education, reducing inequality, and spurring economic growth? We'd like to help.

Become a contributor

Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.

Welcome to the developer cloud

DigitalOcean makes it simple to launch in the cloud and scale up as you grow — whether you're running one virtual machine or ten thousand.

Learn more
DigitalOcean Cloud Control Panel