Nginx 403 Forbidden error on a simple conf file

  • Posted October 6, 2019
  • Nginx

I’ve got a new Ubuntu 18.04 droplet on DO, by following this guide. Just installed Nginx and Ufw (which is disabled for now) on it. I’ve this conf file inside the /etc/nginx/conf.d folder.

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

        root /var/www/2;
        index index.html index.htm index.nginx-debian.html;


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

In the error log, this is written *7 directory index of "/var/www/2/" is forbidden, client:, server:, request: "GET / HTTP/1.1", host: ""

I’ve also tried commenting out the 3rd line from last, i.e. try_files line. But it still behaves the same. Pls help what is preventing me to access the index.html lying inside /var/www/2 folder.

And if I used below given text in that …/conf.d/2.conf file (replacing what is already there), then also it doesn’t succeed (rather falls back on serving the /usr/share/nginx/html/index.html).

server {
        listen 80; listen [::]:80;
        server_name;  # <-- change this

        location /.well-known/acme-challenge/ {
                root /var/www;

        location / {
                return 301 https://$host$request_uri;


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

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.

I deleted that ‘default’ file (or its link in the sites-enabled).

Index file is serving ok from that very location /var/www/2. I’ve copied that very file from some other working locations.

Hello, @zopfans

Can you check the site configuration file and make sure everything is okay? The one in:


and see the root directory of the site itself. Let me know how it goes.