Permalink
Branch: master
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
70 lines (56 sloc) 2.6 KB
{{ ansible_managed | comment(decoration="; ") }}
; source: https://github.com/mholt/caddy/blob/master/dist/init/linux-systemd/caddy.service
; version: 6be0386
; changes: Set variables via Ansible
[Unit]
Description=Caddy HTTP/2 web server
Documentation=https://caddyserver.com/docs
After=network-online.target
{% if caddy_systemd_network_dependency == true %}
Wants=network-online.target systemd-networkd-wait-online.service
{% endif %}
[Service]
Restart={{ caddy_systemd_restart }}
StartLimitInterval={{ caddy_systemd_restart_startlimitinterval }}
StartLimitBurst= {{ caddy_systemd_restart_startlimitburst }}
; User and group the process will run as.
User={{ caddy_user }}
Group={{ caddy_user }}
; Letsencrypt-issued certificates will be written to this directory.
Environment=CADDYPATH={{ caddy_certs_dir }}
; Always set "-root" to something safe in case it gets forgotten in the Caddyfile.
ExecStart={{ caddy_bin_dir }}/caddy -log {{ caddy_log_file }} -http2={{ caddy_http2_enabled }} -agree=true -conf={{ caddy_conf_dir }}/Caddyfile -root=/var/tmp {{ caddy_additional_args }}
ExecReload=/bin/kill -USR1 $MAINPID
; Limit the number of file descriptors; see `man systemd.exec` for more limit settings.
LimitNOFILE=1048576
{% if caddy_systemd_nproc_limit > 0 %}
; Limit the number of caddy threads.
LimitNPROC={{ caddy_systemd_nproc_limit }}
{% endif %}
; Use private /tmp and /var/tmp, which are discarded after caddy stops.
PrivateTmp={{ caddy_systemd_private_tmp }}
; Use a minimal /dev
PrivateDevices={{ caddy_systemd_private_devices }}
; Hide /home, /root, and /run/user. Nobody will steal your SSH-keys.
ProtectHome={{ caddy_systemd_protect_home }}
; Make /usr, /boot, /etc and possibly some more folders read-only.
ProtectSystem={{ caddy_systemd_protect_system }}
; … except {{ caddy_certs_dir }}, because we want Letsencrypt-certificates there.
; This merely retains r/w access rights, it does not add any new. Must still be writable on the host!
ReadWriteDirectories={{ caddy_certs_dir }}
{% if caddy_systemd_capabilities_enabled %}
; The following additional security directives only work with systemd v229 or later.
; They further retrict privileges that can be gained by caddy.
; Note that you may have to add capabilities required by any plugins in use.
CapabilityBoundingSet={{ caddy_systemd_capabilities }}
AmbientCapabilities={{ caddy_systemd_capabilities }}
NoNewPrivileges=true
{% endif %}
{% if caddy_environment_variables|length %}
; Additional environment variables:
{% for key, value in caddy_environment_variables.items() %}
Environment={{ key }}={{ value }}
{% endfor %}
{% endif %}
[Install]
WantedBy=multi-user.target