nginx: update systemd unit using nginx recommendation

Our systemd unit doesn't follow the official
recommendation, see
    https://www.nginx.com/resources/wiki/start/topics/examples/systemd/

Most importantly:
* it should start after some additional specific
  targets/units
* using PrivateTmp is a useful security feature, in
  particular to avoid cross domain scripting via the
  temp folder
* using systemd's $MAINPID, we can distinguish between
  multiple running nginx instances correctly

Signed-off-by: André Draszik <andre.draszik@jci.com>
Signed-off-by: Khem Raj <raj.khem@gmail.com>
This commit is contained in:
André Draszik 2019-01-18 14:26:10 +00:00 committed by Khem Raj
parent d417b693a5
commit a0eadda910
2 changed files with 8 additions and 3 deletions

View File

@ -1,11 +1,15 @@
[Unit]
Description=Nginx Server
After=network.target
Description=The NGINX HTTP and reverse proxy server
After=syslog.target network.target remote-fs.target nss-lookup.target
[Service]
Type=forking
PIDFile=/run/nginx/nginx.pid
ExecStartPre=@SBINDIR@/nginx -t
ExecStart=@SBINDIR@/nginx
ExecStop=@SBINDIR@/nginx -s stop
ExecReload=@SBINDIR@/nginx -s reload
ExecStop=@BINDIR@/kill -s QUIT $MAINPID
PrivateTmp=true
[Install]
WantedBy=multi-user.target

View File

@ -117,6 +117,7 @@ do_install () {
sed -i -e 's,@SYSCONFDIR@,${sysconfdir},g' \
-e 's,@LOCALSTATEDIR@,${localstatedir},g' \
-e 's,@SBINDIR@,${sbindir},g' \
-e 's,@BINDIR@,${bindir},g' \
${D}${systemd_unitdir}/system/nginx.service
fi
}