systemd.service 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. [Unit]
  2. Description=User-friendly AI Interface (Supports Ollama, OpenAI API, ...)
  3. After=network.target
  4. [Service]
  5. Type=simple
  6. User=__APP__
  7. Group=__APP__
  8. WorkingDirectory=__INSTALL_DIR__/
  9. EnvironmentFile=__INSTALL_DIR__/.env
  10. ExecStart=/usr/bin/bash -c 'source __INSTALL_DIR__/venv/bin/activate && open-webui serve --port __PORT__'
  11. StandardOutput=append:/var/log/__APP__/__APP__.log
  12. StandardError=inherit
  13. TimeoutStartSec=300
  14. ### Depending on specificities of your service/app, you may need to tweak these
  15. ### .. but this should be a good baseline
  16. # Sandboxing options to harden security
  17. # Details for these options: https://www.freedesktop.org/software/systemd/man/systemd.exec.html
  18. NoNewPrivileges=yes
  19. PrivateTmp=yes
  20. PrivateDevices=yes
  21. RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK
  22. RestrictNamespaces=yes
  23. RestrictRealtime=yes
  24. DevicePolicy=closed
  25. ProtectClock=yes
  26. ProtectHostname=yes
  27. ProtectProc=invisible
  28. ProtectSystem=full
  29. ProtectControlGroups=yes
  30. ProtectKernelModules=yes
  31. ProtectKernelTunables=yes
  32. LockPersonality=yes
  33. SystemCallArchitectures=native
  34. SystemCallFilter=~@clock @debug @module @mount @obsolete @reboot @setuid @swap @cpu-emulation @privileged
  35. # Denying access to capabilities that should not be relevant for webapps
  36. # Doc: https://man7.org/linux/man-pages/man7/capabilities.7.html
  37. CapabilityBoundingSet=~CAP_RAWIO CAP_MKNOD
  38. CapabilityBoundingSet=~CAP_AUDIT_CONTROL CAP_AUDIT_READ CAP_AUDIT_WRITE
  39. CapabilityBoundingSet=~CAP_SYS_BOOT CAP_SYS_TIME CAP_SYS_MODULE CAP_SYS_PACCT
  40. CapabilityBoundingSet=~CAP_LEASE CAP_LINUX_IMMUTABLE CAP_IPC_LOCK
  41. CapabilityBoundingSet=~CAP_BLOCK_SUSPEND CAP_WAKE_ALARM
  42. CapabilityBoundingSet=~CAP_SYS_TTY_CONFIG
  43. CapabilityBoundingSet=~CAP_MAC_ADMIN CAP_MAC_OVERRIDE
  44. CapabilityBoundingSet=~CAP_NET_ADMIN CAP_NET_BROADCAST CAP_NET_RAW
  45. CapabilityBoundingSet=~CAP_SYS_ADMIN CAP_SYS_PTRACE CAP_SYSLOG
  46. [Install]
  47. WantedBy=multi-user.target