nginx & systemd Example
A practical self-hosted process and reverse-proxy baseline for a root-domain installation.
On this page 5
What you will learn
- Supervise the Node process.
- Proxy public traffic.
- Verify service and HTTP health.
Prerequisites
- A Linux host
- nginx
- A dedicated unprivileged service account
systemd service
Adjust paths, user, port, and environment location for your server. Keep the service account unprivileged.
ini
[Unit]
Description=Your Nexus application
After=network.target
[Service]
Type=simple
User=nexus
WorkingDirectory=/srv/your-app/current
Environment=NODE_ENV=production
Environment=PORT=3000
ExecStart=/usr/bin/corepack pnpm start
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.targetnginx server
Terminate TLS using your certificate automation and proxy requests to the local Node port.
nginx
server {
listen 443 ssl http2;
server_name admin.example.com;
location / {
proxy_pass http://127.0.0.1:3000;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}Activate and verify
Validate both configurations before reloading public traffic.
bash
sudo systemctl daemon-reload
sudo systemctl enable --now your-nexus.service
systemctl is-active your-nexus.service
sudo nginx -t
sudo systemctl reload nginx
curl -I https://admin.example.com/dashboardOperational hardening
Add service resource limits, centralized logs, health monitoring, deployment rollback, and firewall rules appropriate to your environment.