I'm using nginx (Port 8888) as a reverse proxy for my web server running over 8080. In the traditional way, nginx master process runs as root and spawns the child processes with user www-data. Is it recommended to run the master process as non-root as well to harden the security of my machine?

Both nginx and reverse proxy are running on same ubuntu machine.

1 Answer 1


It depends.
One reason to run nginx as root is to make it possible to listen on ports below 1024 i.e. port 80 (http) and port 443 (https). This is not needed in your case. Another reason is to make it possible for nginx to read sensitive files like certificate private keys on startup without having these file readable in case a child process gets compromised.

Thus, one the one side you have the risk that something is at least initially running as root. On the other side you have the risk of exposing sensitive files to the non-root part of nginx, i.e. the part which does the main work and were the main code complexity is. Which of these risks is more relevant depends on your actual use case, i.e. are there sensitive files like private keys involved in your configuration, do you explicitly need to give some not fully trusted user root to start nginx etc.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .