systemd.service 1.7 KB

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