# Netwall systemd unit (Debian 13 LXC; see docs/DEPLOY.md). # # install -m 0644 deploy/netwall.service /etc/systemd/system/netwall.service # systemctl daemon-reload && systemctl enable --now netwall # journalctl -u netwall -f # # Expects the app in /opt/netwall (server/, public/, node_modules/) and Debian's /usr/bin/node (Node 20). [Unit] Description=Netwall - co-op tower defence (Node server) Documentation=file:///opt/netwall/docs/DEPLOY.md After=network-online.target Wants=network-online.target [Service] Type=simple User=netwall Group=netwall WorkingDirectory=/opt/netwall ExecStart=/usr/bin/node /opt/netwall/server/index.js # ---- configuration (see docs/DEPLOY.md, "Configuration") -------------------------------------- Environment=NODE_ENV=production # Port to listen on. 8080 is unprivileged, so the service needs no capabilities. Environment=PORT=8080 # "::" = one dual-stack socket for IPv4 + IPv6 (falls back to 0.0.0.0 if the kernel has no IPv6). Environment=HOST=:: # auto: believe X-Forwarded-For / X-Forwarded-Host only from loopback / private-range peers (your proxy). Environment=TRUST_PROXY=auto # Only needed when the proxy rewrites the Host header (symptom: 403 on the WebSocket upgrade). # Comma separated, e.g. https://game.example.com #Environment=ALLOWED_ORIGINS=https://game.example.com #Environment=MAX_CONN_PER_IP=40 #Environment=GRACE_MS=60000 # ---- lifecycle --------------------------------------------------------------------------------- Restart=on-failure RestartSec=2 # SIGTERM closes all sockets and exits 0 within about a second; SIGKILL after 10 s as a backstop. TimeoutStopSec=10 # ---- hardening that works in any container (no mount namespaces needed) ----------------------- NoNewPrivileges=yes CapabilityBoundingSet= AmbientCapabilities= # AF_NETLINK: Node's os.networkInterfaces() (start-up banner) and glibc's resolver use it. RestrictAddressFamilies=AF_INET AF_INET6 AF_UNIX AF_NETLINK RestrictRealtime=yes RestrictSUIDSGID=yes LockPersonality=yes SystemCallArchitectures=native UMask=0077 # Do NOT add MemoryDenyWriteExecute=yes: V8's JIT needs writable+executable memory and Node would crash. # ---- optional extra hardening: needs mount namespaces ------------------------------------------ # In an unprivileged Proxmox LXC these fail with "status=226/NAMESPACE" unless the container has the # "Nesting" feature enabled (Proxmox: container > Options > Features > Nesting; then restart the CT). # The app writes nothing to disk, so a read-only file system view is fine for it. #ProtectSystem=strict #ProtectHome=yes #PrivateTmp=yes #PrivateDevices=yes #ProtectKernelTunables=yes #ProtectKernelModules=yes #ProtectKernelLogs=yes #ProtectControlGroups=yes #ProtectClock=yes #ProtectHostname=yes [Install] WantedBy=multi-user.target