403 Forbidden on nginx web server

hello support,

  1. i Create a Self-Signed TLS Certificate
    by following this guide
    https://www.linode.com/docs/security/ssl/create-a-self-signed-tls-certificate/

  2. i enable TLS for HTTPS Connections
    by following this guide
    https://www.linode.com/docs/web-servers/nginx/enable-tls-on-nginx-for-https-connections/

so, at the end

  1. i have this 403 Forbidden, when open my website,
    https://example.com

  2. i log the error, on, /var/log/nginx/example.com-ssl-error.log;

    2019/11/14 08:43:25 [error] 13930#13930: *1858
    directory index of "/home/forge/example.com/public/" is forbidden,
    client: 182.1.211.181….

    Note: i am using laravel framework

  3. on, /etc/nginx/conf.d/example.com.conf

    server {
    listen 443 ssl default_server;
    listen [::]:443 ssl default_server ;
    server_name example.com www.example.com;
    root /home/forge/wahsidin.com/public;
    access_log /var/log/nginx/wahsidin.com-ssl-access.log;
    error_log /var/log/nginx/wahsidin.com-ssl-error.log;
    }

  4. What is missing on my configuration ? can anyone help me ?

2 Replies

I don't use nginx but

directory index of "somepath" is forbidden

usually means that your web server is not configured correctly. See:

https://stackoverflow.com/questions/19285355/nginx-403-error-directory-index-of-folder-is-forbidden

-- sw

@pinosin If that's all the content of your nginx configuration, you need a root (/) location with a try_files directive.

server {
    listen 443 ssl default_server;
    listen [::]:443 ssl default_server ;
    server_name example.com www.example.com;
    root /home/forge/wahsidin.com/public;
    access_log /var/log/nginx/wahsidin.com-ssl-access.log;
    error_log /var/log/nginx/wahsidin.com-ssl-error.log;

    location / {
        try_files $uri $uri/ =404;
    }
}

https://nginx.org/en/docs/http/ngx_http_index_module.html#index

You might want to use the recommended Nginx configuration for Laravel:

https://laravel.com/docs/6.x/deployment

Also keep in mind that you would need to add index with a list of possible index files (like index.php) and FastCGI configuration if you plan to run a PHP web application. See the previous link.

Also make sure that the user specified in your nginx.conf file has read and execute permissions. You could use setfacl to set permissions for the user without the need of changing directory owner with chown.

Example (see man setfacl for more information):

setfacl -R -m user:{USER}:rx,d:user:{USER}:rx /home/forge/wahsidin.com/public

Just replace {USER} with the one you've specified in your nginx.conf file.

Worth reading:

Reply

Please enter an answer
Tips:

You can mention users to notify them: @username

You can use Markdown to format your question. For more examples see the Markdown Cheatsheet.

> I’m a blockquote.

I’m a blockquote.

[I'm a link] (https://www.google.com)

I'm a link

**I am bold** I am bold

*I am italicized* I am italicized

Community Code of Conduct