systemd.service 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546
  1. [Unit]
  2. Description=flohmarkt server
  3. After=network.target couchdb.service
  4. [Service]
  5. Type=simple
  6. User=__APP__
  7. Group=__APP__
  8. WorkingDirectory=__INSTALL_DIR__/__APP__
  9. Environment="VENV_DIR=__INSTALL_DIR__/venv/"
  10. ExecStart=__INSTALL_DIR__/venv/bin/uvicorn --host 127.0.0.1 --port __PORT__ --reload flohmarkt.web:start
  11. StandardOutput=append:/var/log/__APP__/__APP__.log
  12. StandardError=inherit
  13. # Sandboxing options to harden security
  14. # Depending on specificities of your service/app, you may need to tweak these
  15. # .. but this should be a good baseline
  16. # Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
  17. NoNewPrivileges=yes
  18. PrivateTmp=yes
  19. PrivateDevices=yes
  20. RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6
  21. RestrictNamespaces=yes
  22. RestrictRealtime=yes
  23. DevicePolicy=closed
  24. ProtectSystem=full
  25. ProtectControlGroups=yes
  26. ProtectKernelModules=yes
  27. ProtectKernelTunables=yes
  28. LockPersonality=yes
  29. SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap
  30. # Denying access to capabilities that should not be relevant for webapps
  31. # Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
  32. CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
  33. CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
  34. CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
  35. CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
  36. CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
  37. CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
  38. CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
  39. CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
  40. CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
  41. [Install]
  42. WantedBy=multi-user.target