Can I specify a different user instead of "nobody"?

For example root? or the user who usually logs in?

Second question.

And also, now on my conf file (nginx.conf) this user is commented out. #user nobody ... so when I run nginx, does it run under what user?

  • 2
    1) It is possible, but not necessary; 2) Run and look at the user in the list of processes, why ask us - andreymal

1 answer 1

The user directive speaks about the user under which to start the process Nginx . Running Nginx as root is a very bad idea. If an attacker finds a vulnerability in Nginx, PHP or something else that starts Nginx, then he will immediately get root rights to the entire system.

Hence the consequence - it would be nice to run Nginx from under such a user who has all the sufficient rights in the system to perform his tasks, but does not have any redundant rights. This is called the principle least privelege .

In general, such a user in the system already exists and this is the same nobody : https://wiki.ubuntu.com/nobody . Therefore, if you register in the config of some other user, then you need to understand very well why this is done and what it will lead to. Your user settings were not tested as well as nobody , and if you made a mistake somewhere - well, you live with it.

And yet, right now in my conf file (nginx.conf) this user is commented out. #user nobody ... so when I run nginx, does it run under what user?

It is best to run ps and check it out.