Skip to content

Instantly share code, notes, and snippets.

@clemensg
Created November 22, 2017 22:08
Show Gist options
  • Save clemensg/7dd024169efe8ce6e7fa4a0b3caa3780 to your computer and use it in GitHub Desktop.
Save clemensg/7dd024169efe8ce6e7fa4a0b3caa3780 to your computer and use it in GitHub Desktop.
Example nginx service file for systemd
[Unit]
Description=NGINX HTTP and reverse proxy server
After=syslog.target network.target nss-lookup.target
[Service]
Type=forking
PIDFile=/var/run/nginx.pid
ExecStartPre=/usr/sbin/nginx -t
ExecStart=/usr/sbin/nginx
ExecReload=/usr/bin/kill -s HUP $MAINPID
ExecStop=/usr/bin/kill -s QUIT $MAINPID
# Hardening
InaccessiblePaths=/etc/gnupg /etc/shadow /etc/ssh
ProtectSystem=full
ProtectKernelTunables=yes
ProtectControlGroups=yes
SystemCallFilter=~@clock @cpu-emulation @debug @keyring @module @mount @obsolete @raw-io
MemoryDenyWriteExecute=yes
RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX
RestrictRealtime=yes
[Install]
WantedBy=multi-user.target
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment