Skip to content
Advertisement

Laravel on nginx displays 403, but my path is correct

I have a digitalocean droplet and I want to run a laravel project. I used this tutorial https://www.digitalocean.com/community/tutorials/how-to-deploy-a-laravel-application-with-nginx-on-ubuntu-16-04

The thing is that it displays a 403. I saw on other questions that they missed the public directory or they had the path wrong, but in my case I got a 403 when I have the public dir correct, and a 500 when I have it wrong.

My nginx error log says

2017/09/29 13:58:16 [error] 15176#15176: *2 directory index of "/var/www/laravel/public/" is forbidden

My nginx sites-available/my-site.com

server {
        listen 80;
        listen [::]:80;

        # SSL configuration
        #
        # listen 443 ssl default_server;
        # listen [::]:443 ssl default_server;
        #
        # Note: You should disable gzip for SSL traffic.
        # See: https://bugs.debian.org/773332
        #
        # Read up on ssl_ciphers to ensure a secure configuration.
        # See: https://bugs.debian.org/765782
        #
        # Self signed certs generated by the ssl-cert package
        # Don't use them in a production server!
        #
        # include snippets/snakeoil.conf;

        root /var/www/laravel/public;

        # Add index.php to the list if you are using PHP
        index index.html index.htm index.nginx-debian.html;

        server_name my-site.com www.my-site.com;

        location / {
                # First attempt to serve request as file, then
                # as directory, then fall back to displaying a 404.
                try_files $uri $uri/ /index.php?$query_string;
        }

Advertisement

Answer

The answer is right there in your nginx config. It is also shown in the tutorial you link to.

# Add index.php to the list if you are using PHP
index index.html index.htm index.nginx-debian.html;

You have not added index.php.

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement