NGINX won’t serve HTML files from root dir under www-data user

Have NGINX serving website from root dir /home/ubuntu/frontend

nginx.conf:

#user www-data;
user ubuntu;

sites-enabled:

server {
        server_name giftbutton.live;
        listen 80;

        root /home/ubuntu/frontend;
        index index.html;
        }

the directory:

drwxrwxrwx  4 www-data www-data  4096 Jan 11 22:36 frontend

At the moment the dir has silly 777 access for testing purposes. The directory is being served fine as long as in nginx.conf user is ubuntu. But the website should be served as user www-data. The moment I change user in nginx.conf to www-data , I get error 403.

User www-data does exist in the system:

www-data:x:33:33:www-data:/var/www:/usr/sbin/nologin

Nginx service runs as user ubuntu on the machine. This is how Nginx installs and I haven’t touched it.

The question is why then Nginx refuses to serve the directory as user www-data, when the directory is owned by this user?

Any ideas very appreciated!

Update:

While remaining Nginx user as www-data, I changed the dir access to:

dr-x------  4 www-data ubuntu  4096 Jan 11 23:03 frontend

and still no luck.

Read more here: Source link