1

I logged onto RedHat 7.2 server. sudo to root. In the ngixx.conf file (1.11.7) I added a UDP stream entry for reverse proxy port forwarding to another server:

stream { server { listen 82 udp; proxy_pass xyz:16700; } }

Syntax check is passed:

# nginx -t nginx: the configuration file /etc/nginx/nginx.conf syntax is ok 
           nginx: configuration file /etc/nginx/nginx.conf test is successful

Restarted the server failed:

# service nginx restart 


Journal Logs:

Dec 20 04:46:23 esp-ss960-1-lnx-vm systemd[1]: Starting nginx - high performance web server...
Dec 20 04:46:23 esp-ss960-1-lnx-vm nginx[64702]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Dec 20 04:46:23 esp-ss960-1-lnx-vm nginx[64702]: nginx: [emerg] bind() to 0.0.0.0:82 failed (13: Permission denied)
Dec 20 04:46:23 esp-ss960-1-lnx-vm nginx[64702]: nginx: configuration file /etc/nginx/nginx.conf test failed
Dec 20 04:46:23 esp-ss960-1-lnx-vm systemd[1]: nginx.service: control process exited, code=exited status=1
Dec 20 04:46:23 esp-ss960-1-lnx-vm systemd[1]: Failed to start nginx - high performance web server.
Dec 20 04:46:23 esp-ss960-1-lnx-vm systemd[1]: Unit nginx.service entered failed state.
Dec 20 04:46:23 esp-ss960-1-lnx-vm systemd[1]: nginx.service failed.

++++++++++++++++++++++++++++++++++++++++++

Dec 20 16:22:37 esp-ss960-1-lnx-vm polkitd[543]: Registered Authentication Agent for unix-process:20990:12402078 (system bus name :1.596 [/usr/bin/pkttyagent --notif
Dec 20 16:22:37 esp-ss960-1-lnx-vm systemd[1]: Starting nginx - high performance web server...
-- Subject: Unit nginx.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has begun starting up.
Dec 20 16:22:38 esp-ss960-1-lnx-vm nginx[21007]: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Dec 20 16:22:38 esp-ss960-1-lnx-vm nginx[21007]: nginx: [emerg] open() "/var/run/nginx.pid" failed (13: Permission denied)
Dec 20 16:22:38 esp-ss960-1-lnx-vm nginx[21007]: nginx: configuration file /etc/nginx/nginx.conf test failed
Dec 20 16:22:38 esp-ss960-1-lnx-vm systemd[1]: nginx.service: control process exited, code=exited status=1
Dec 20 16:22:38 esp-ss960-1-lnx-vm systemd[1]: Failed to start nginx - high performance web server.
-- Subject: Unit nginx.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit nginx.service has failed.
--
-- The result is failed.
Dec 20 16:22:38 esp-ss960-1-lnx-vm systemd[1]: Unit nginx.service entered failed state.
Dec 20 16:22:38 esp-ss960-1-lnx-vm systemd[1]: nginx.service failed.
Dec 20 16:22:38 esp-ss960-1-lnx-vm polkitd[543]: Unregistered Authentication Agent for unix-process:20990:12402078 (system bus name :1.596, object path /org/freedesk

what could be the problem here? Thank you

  • [emerg] bind() to 0.0.0.0:82 failed (13: Permission denied) – Ipor Sircer Dec 21 '16 at 18:26
  • and [emerg] open() "/var/run/nginx.pid" failed (13: Permission denied). Something is quite wrong. – Rui F Ribeiro Dec 21 '16 at 18:37
3

SELinux is very probably preventing nginx to start with that new port configuration. You can verify this by disabling SELinux for a moment with setenforce 0 and after that trying to restart nginx. You can check whether SELinux is enabled with geteneforce command.

Also audit log probably will have some entries relating to this incident, if it was SELinux that prevented nginx from starting. Based on those log entries may be able to generate correct rules for SElinux. Heres a good article from red hat for that Allowing Access: audit2allow.

Of course you can completely disable SELinux. That can be done by editing file /etc/selinux/config.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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