Nginx is giving 502 Bad Gateway, with user www-data and works when user is root
trying to debug this for the last two days, but I could not figure out what's wrong
these are my permissions for the socket file
srw-rw-rw- 1 www-data www-data 0 Oct 10 02:48 cafe.sock
and my nginx.conf
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
with this conf I am getting this error "502 bad gateway"
cafe.sock failed (13: Permission denied) while connecting to the upstream, client: 106.217.200.51, server: 65. 2.186.229, request: "GET /favicon.ico HTTP/1.1", upstream: "uwsgi://unix:/home/ubuntu/lakegarden/cafe.sock:", host: "65.2.186.229", referrer: "http://65.2.186.229/admin/"
after changing
user root;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
it is working fine, I can see the admin panel, but read it in SO that we should not have root as a user for security reasons. is there something that i am missing.
thank you