nethubonline
Regular Pleskian
Under OpenVZ VM, Nginx starts getting failure because cannot bind to IP port 80, the reason is that the network is not yet fully started so that no IP configured during Nginx starting.
Apr 6 15:45:43 c9 systemd: Starting Startup script for nginx service...
Apr 6 15:45:43 c9 nginx: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Apr 6 15:45:43 c9 nginx: nginx: [emerg] bind() to 1.2.3.4:80 failed (99: Cannot assign requested address)
Apr 6 15:45:43 c9 nginx: nginx: configuration file /etc/nginx/nginx.conf test failed
Apr 6 15:45:43 c9 systemd: nginx.service: control process exited, code=exited status=1
Apr 6 15:45:43 c9 systemd: Failed to start Startup script for nginx service.
Apr 6 15:45:43 c9 systemd: Unit nginx.service entered failed state.
Apr 6 15:45:43 c9 systemd: nginx.service failed.
After system fully start up, systemctl restart nginx can start the nginx without problem because at this time IP exists already.
Tested that modify /usr/lib/systemd/system/nginx.service which fix the problem, but I am not sure whether this is good to start after network-online.target :
[old]
After=network.target remote-fs.target nss-lookup.target
[new]
After=network-online.target remote-fs.target nss-lookup.target
Confirmed that no this problem in non OpenVZ VM, because NetworkManager starts eariler than Nginx
Apr 6 15:45:43 c9 systemd: Starting Startup script for nginx service...
Apr 6 15:45:43 c9 nginx: nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
Apr 6 15:45:43 c9 nginx: nginx: [emerg] bind() to 1.2.3.4:80 failed (99: Cannot assign requested address)
Apr 6 15:45:43 c9 nginx: nginx: configuration file /etc/nginx/nginx.conf test failed
Apr 6 15:45:43 c9 systemd: nginx.service: control process exited, code=exited status=1
Apr 6 15:45:43 c9 systemd: Failed to start Startup script for nginx service.
Apr 6 15:45:43 c9 systemd: Unit nginx.service entered failed state.
Apr 6 15:45:43 c9 systemd: nginx.service failed.
After system fully start up, systemctl restart nginx can start the nginx without problem because at this time IP exists already.
Tested that modify /usr/lib/systemd/system/nginx.service which fix the problem, but I am not sure whether this is good to start after network-online.target :
[old]
After=network.target remote-fs.target nss-lookup.target
[new]
After=network-online.target remote-fs.target nss-lookup.target
Confirmed that no this problem in non OpenVZ VM, because NetworkManager starts eariler than Nginx