Blueprints · Node.js & Next.js
Production
10 min · Node.js
Next.js bound for a local proxy
Stages a systemd snippet that listens on 127.0.0.1 so Nginx is the public server.
Why this should not be public
If the Node process listens on 0.0.0.0:3000 next to nginx, visitors can skip nginx entirely, and with it TLS, security headers and rate limits.
Live config
Baked-in protections
- Next listens on 127.0.0.1
- The public ports stay on the proxy
- The unit is staged
Step 1 · ini
Service snippet
/root/portgate-blueprints/next.service
Use this ExecStart for a next start deployment.
[Service] User=node WorkingDirectory=/opt/app Environment=HOSTNAME=127.0.0.1 Environment=PORT=3000 ExecStart=/usr/bin/npm run start NoNewPrivileges=true
Step 2 · bash
Read-only check
/root/portgate-blueprints/next-port-check.sh
Prints status. It does not change the service.
#!/bin/sh set -eu ss -tulpn | grep "3000" || echo "Nothing is listening on 3000."