Question
Nginx 403 Forbidden error on a simple conf file
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;
server_name 2.hotelbobbygg.xyz;
location / {
try_files $uri $uri/ =404;
}
}
In the error log, this is written *7 directory index of "/var/www/2/" is forbidden, client: 139.5.37.198, server: 2.hotelbobbygg.xyz, request: "GET / HTTP/1.1", host: "2.hotelbobbygg.xyz"
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 2.hotelbobbygg.xyz; # <-- change this
location /.well-known/acme-challenge/ {
root /var/www;
}
location / {
return 301 https://$host$request_uri;
}
}
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.
×