You are not logged in.

#1 2014-09-12 22:28:30

nobody44
Member
Registered: 2011-08-25
Posts: 29

Systemd and Nginx

Hello,

I spent the last 5 hours figuring out how to configure nginx and systemd properly. I got mad and gave up.

The nginx webserver listens on two interfaces (tun0: 10.8.0.1, enp3s0: 192.168.1.5).
I used (!) the dhcpcd service from systemd, but I couldn't get the nginx service to wait until the service got an IP address (the 192.... address). So I switched to systemd-networkd.

My dhcp.network file in /etc/systemd/network/:

[Match]
Name=enp3s0

[Network]
DHCP=both

I enabled systemd-networkd.service and systemd-networkd-wait-online.service. My nginx.service file in /etc/systemd/system:

[Unit]
Description=A high performance web server and a reverse proxy server
Requires=network.target openvpn@server.service  ### I tried network-online.target as well, nothing changed
Wants=network.target openvpn@server.service  ### I tried network-online.target as well, nothing changed
After=network.target openvpn@server.service  ### I tried network-online.target as well, nothing changed

[Service]
Type=forking
PIDFile=/run/nginx.pid
PrivateDevices=yes
SyslogLevel=err

ExecStart=/usr/bin/nginx -g 'pid /run/nginx.pid; error_log stderr;'
ExecReload=/usr/bin/kill -HUP $MAINPID
KillSignal=SIGQUIT
KillMode=mixed

[Install]
WantedBy=multi-user.target

I am out of ideas... I tried different approaches, even NetworkManager with static IPs (and NetworkManager-online-wait.service), nothing worked.

I thought this systemd-networkd-wait-online service was supposed to do *anything*. But I was wrong:

┌─[root@zbox] [~]
└──>systemctl status systemd-networkd-wait-online.service 
● systemd-networkd-wait-online.service - Wait for Network to be Configured
   Loaded: loaded (/usr/lib/systemd/system/systemd-networkd-wait-online.service; enabled)
   Active: inactive (dead)
     Docs: man:systemd-networkd-wait-online.service(8)

Could anyone explain to me, why on earth the service is *enabled* but *inactive*?!
I am really mad right now, so forgive me. But from now on I hate systemd... seriously...

With Requires=... I got the service running, but nginx still won't start automatically.

I hope you can help me

Paul

Last edited by nobody44 (2014-09-12 22:38:34)

Offline

Board footer

Powered by FluxBB