systemd.service 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. [Unit]
  2. Description=Homarr
  3. After=network.target
  4. [Service]
  5. Type=simple
  6. User=__APP__
  7. Group=__APP__
  8. WorkingDirectory=__FINALPATH__/
  9. Environment="PATH=__ENV_PATH__"
  10. Environment="NODE_ENV=production"
  11. Environment="PORT=__PORT__"
  12. ExecStart=/usr/bin/yarn start
  13. Restart=on-failure
  14. RestartSec=5
  15. StartLimitInterval=60s
  16. StartLimitBurst=3
  17. # Sandboxing options to harden security
  18. # Depending on specificities of your service/app, you may need to tweak these
  19. # .. but this should be a good baseline
  20. # Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
  21. NoNewPrivileges=yes
  22. PrivateTmp=yes
  23. PrivateDevices=yes
  24. RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
  25. RestrictNamespaces=yes
  26. RestrictRealtime=yes
  27. DevicePolicy=closed
  28. ProtectClock=yes
  29. ProtectHostname=yes
  30. ProtectProc=invisible
  31. ProtectSystem=full
  32. ProtectControlGroups=yes
  33. ProtectKernelModules=yes
  34. ProtectKernelTunables=yes
  35. LockPersonality=yes
  36. SystemCallArchitectures=native
  37. SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap @cpu-emulation @privileged
  38. # Denying access to capabilities that should not be relevant for webapps
  39. # Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
  40. CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
  41. CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
  42. CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
  43. CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
  44. CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
  45. CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
  46. CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
  47. CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
  48. CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
  49. [Install]
  50. WantedBy=multi-user.target