1

I installed nginx-extras in order to use lua module. I use mongroup to group and start services on my machine.

When I run nginx with this command:

    exec nginx -c "$(pwd)/nginx.conf" -g "daemon off;"

I get:

    2015/08/21 12:20:03 [debug] 24217#0: bind() 0.0.0.0:80 #5
    2015/08/21 12:20:03 [emerg] 24217#0: bind() to 0.0.0.0:80 failed(13:    Permission denied)

I have seen some post where it says that I have to launch nginx as root user because only root user can use port 80. So I added:

    user root;

to my nginx.conf. After this, nothing change and I still get this issue.

  • 1
    Could you edit the output of getenforce into your question? Which user as you running the exec nginx command as? Becoming root means more than just asking for it in a config file. – MadHatter Aug 21 '15 at 12:44
  • Doesn't nginx come with an init script such that it can be started through a more standardized method than this hack? – kasperd Aug 21 '15 at 16:05
6

You cannot open privileged ports (<=1024) as non-root. Telling nginx to run as root is nice, but it can't switch to root from a normal user itself. You could run it inside sudo to start it as root. It would be a bad idea to run it as root forever so you should put a non-privileged user in there so nginx can run without making your machine easier to attack.

| improve this answer | |

Not the answer you're looking for? Browse other questions tagged or ask your own question.