Home > Back-end >  nginx is giving 502 Bad Gateway, with user www-data and works when user is root
nginx is giving 502 Bad Gateway, with user www-data and works when user is root

Time:10-11

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

CodePudding user response:

set this in nginx.conf user ubuntu; then restart nginx enter image description here

  • Related