PortGate

Setup library

Hardened stack and server blueprints

Customize a production setup, then copy or download the rendered files. SSH password login is left on until a public key is in place.

Build a bundle
Zero-Trust 25 min

Alpine Linux v3.21 minimal VPS and container host hardening

Server Hardening · Alpine Linux

Adds a wheel user with doas, locks root only after a public key exists, and applies a persistent stateful iptables policy that still accepts SSH.

Customize & Copy →
Beginner 15 min

Caddy 2 automatic HTTPS reverse proxy and hardened headers

Reverse Proxy & SSL · Caddy

Lets stock Caddy obtain the certificate, enables HTTP/3, strips the Server header, and proxies to a localhost port. Request rate limits need an extra Caddy module, so they are not in the validated file.

Customize & Copy →
Zero-Trust 20 min

Cloudflare Tunnel zero-open-port ingress

Server Hardening · cloudflared

Publishes a local app through an outbound cloudflared tunnel. Removing public firewall allows is a separate script and does not run until the tunnel is active. SSH is removed only when you set CLOSE_SSH to yes.

Customize & Copy →
Production 20 min

Docker Engine daemon hardening and UFW-safe publishes

Docker & Databases · Docker

Sets live restore, blocks new privileges by default, turns off default-bridge snooping, rotates JSON logs, and shows the 127.0.0.1 publish form that keeps Docker from opening a port past UFW.

Customize & Copy →
Production 20 min

Hardened Nginx reverse proxy, TLS 1.3, and grade-A headers

Reverse Proxy & SSL · Nginx

Hides the Nginx version, allows TLS 1.2 and 1.3, sets a header baseline, rate-limits login and API paths, and answers bare-IP requests with an empty close.

Customize & Copy →
Zero-Trust 20 min

Incident response triage playbook

Server Hardening · Linux

Collects processes, listening sockets, recently changed files, SUID binaries, SSH authorized keys, and crontabs into a new directory. It does not stop services or delete files. The bundle does not run it.

Customize & Copy →
Production 40 min

Laravel 12 / 13 bare-metal production stack

Laravel & PHP · Ubuntu 24.04 / Nginx / PHP 8.4

Nginx, PHP 8.4-FPM, Redis on localhost, a queue worker, the scheduler cron, and a deploy script that switches the current symlink after migrations.

Customize & Copy →
Production 25 min

Next.js production self-host with middleware header guard

Node.js & Next.js · Nginx / systemd

Runs a standalone Next.js server as a dedicated user. Nginx clears x-middleware-subrequest before the request reaches the app and caches hashed static files.

Customize & Copy →
Production 25 min

Node.js / Express production setup with PM2

Node.js & Next.js · Node.js / PM2 / Nginx

Runs the app as a dedicated user under PM2, rotates its logs, and proxies WebSocket upgrades to 127.0.0.1:3000.

Customize & Copy →
Production 20 min

Ollama behind the PortGate AI proxy

AI & LLMs · Ollama

Binds Ollama to localhost and sends application traffic through the PortGate AI proxy on 127.0.0.1:8787. Daily request and token caps are written into ai_proxy. Binding localhost is the control for the unauthenticated API exposed by CVE-2024-37032. The agent does not check the Ollama package version.

Customize & Copy →
Beginner 15 min

PortGate agent and dead-man cron wrapper

Systemd & Agents · PortGate

Installs the PortGate agent with --mode all and writes a wrapper that posts to your webhook when a wrapped cron command exits non-zero. The token needs server, AI telemetry, and malware abilities.

Customize & Copy →
Production 30 min

PostgreSQL 17 production hardening and encrypted S3 backups

Docker & Databases · PostgreSQL 17

Listens on localhost, requires SCRAM-SHA-256, turns on SSL, and dumps the database through GPG before an S3 or R2 upload. A success ping is skipped until you replace the heartbeat URL.

Customize & Copy →
Production 25 min

restic encrypted offsite backups

Systemd & Agents · restic

Installs restic and writes a backup of /etc, /var/www, and /var/backups. Retention is 7 daily, 4 weekly, and 6 monthly. The repository password and the run itself stay out of the bundle.

Customize & Copy →
Production 25 min

RHEL 9 / AlmaLinux 9 / Rocky Linux 9 production hardening

Server Hardening · RHEL 9 / AlmaLinux 9 / Rocky Linux 9

Opens SSH, HTTP, and HTTPS in firewalld, keeps SELinux enforcing when it is already enabled, switches sshd to key-only after a public key exists, and turns on dnf-automatic security updates.

Customize & Copy →
Zero-Trust 25 min

Ubuntu 24.04 / Debian 12 zero-trust initial server hardening

Server Hardening · Ubuntu 24.04 / Debian 12

Creates a sudo user, refuses to change sshd until that user has a public key, then enables UFW, Fail2Ban, unattended upgrades, sysctl network hardening, and the PortGate agent.

Customize & Copy →
Production 15 min

UFW-safe Docker Compose for PostgreSQL and Redis

Docker & Databases · Docker

Publishes Postgres and Redis on the host loopback only. Both services drop privileges, keep a read-only root filesystem, and cap memory.

Customize & Copy →
Production 30 min

WordPress high-security and FastCGI cache stack

WordPress · Nginx / PHP-FPM / MariaDB

Denies PHP in uploads, closes xmlrpc.php, rate-limits wp-login.php, sets DISALLOW_FILE_EDIT, and applies 755/644 ownership. MariaDB listens on localhost.

Customize & Copy →
Production 15 min

Adminer on localhost

Docker & Databases · Docker

Publishes Adminer on 127.0.0.1. Reach it through an SSH tunnel.

Customize & Copy →
Beginner 10 min

Application logrotate

Systemd & Agents · Linux

Stages a daily rotation for one application log. It does not delete logs itself.

Customize & Copy →
Production 15 min

auditd file and privilege watch

Server Hardening · auditd

Watches passwd, shadow, sudoers, and sshd_config, and records execve from uid 0. The package is installed when apt or dnf is available.

Customize & Copy →
Beginner 10 min

Certbot renewal timer check

Reverse Proxy & SSL · Nginx

Checks that the certbot timer exists. It does not request a certificate.

Customize & Copy →
Production 15 min

Chroma on localhost

Docker & Databases · Docker

Publishes Chroma on 127.0.0.1 so embeddings are not an internet service.

Customize & Copy →
Beginner 10 min

Chrony time sync

Server Hardening · Linux

Stages a chrony config that uses the distro pool and does not serve time to the internet.

Customize & Copy →
Production 15 min

ClickHouse on localhost

Docker & Databases · Docker

Publishes the ClickHouse HTTP port on 127.0.0.1 and refuses to start while the password is still change-me.

Customize & Copy →
Production 15 min

Cloudflare real client IP

Reverse Proxy & SSL · Nginx

Stages real_ip so logs show the visitor instead of the Cloudflare edge. Update the ranges when Cloudflare publishes new ones.

Customize & Copy →
Beginner 10 min

ComfyUI on localhost

AI & LLMs · Local AI

Stages a ComfyUI listen address of 127.0.0.1. The process is not started.

Customize & Copy →
Beginner 10 min

Composer install without dev dependencies

Laravel & PHP · Linux

Stages a deploy snippet that uses composer install --no-dev from the lockfile.

Customize & Copy →
Production 25 min

Coolify or Dokploy host firewall and backups

Docker & Databases · Coolify / Dokploy

Limits the panel port to an admin address, leaves 80 and 443 open for the apps the panel publishes, and records an encrypted S3 backup target plus the PortGate agent.

Customize & Copy →
Beginner 10 min

Default umask 027

Server Hardening · Linux

Stages a login.defs umask so new files are not world-readable. Existing files are left as they are.

Customize & Copy →
Beginner 10 min

Deny PHP in WordPress uploads

WordPress · Nginx

Stages a location that refuses to execute PHP under wp-content/uploads.

Customize & Copy →
Beginner 10 min

Disable core dumps

Server Hardening · Linux

Stages a systemd default so application crashes do not write memory to disk.

Customize & Copy →
Production 15 min

Docker socket proxy least privilege

Docker & Databases · Docker

Replaces a raw docker.sock mount with tecnativa/docker-socket-proxy. POST is off, the socket is mounted read-only, and the proxy port is localhost.

Customize & Copy →
Production 10 min

DOCKER-USER chain for published ports

Docker & Databases · Docker / iptables

Drops internet traffic to every published container port except the host ports you list, matched on the original port before Docker rewrites it. Survives reboots through a systemd unit. SSH and host services are not in this chain.

Customize & Copy →
Production 15 min

Elasticsearch localhost bind

Docker & Databases · Elasticsearch

Publishes Elasticsearch only on 127.0.0.1 and turns off the single-node HTTP free-for-all by keeping the port off the public interface.

Customize & Copy →
Production 15 min

Fail2Ban jails for SSH, Nginx, and WordPress

Server Hardening · Fail2Ban

Enables sshd, nginx-http-auth, nginx-botsearch, and a WordPress login jail. Ban time increments. Your admin address is ignored.

Customize & Copy →
Production 15 min

Gitea HTTP on localhost

Docker & Databases · Docker

Publishes the Gitea HTTP port on 127.0.0.1. SSH for Git is a separate listener. Do not publish it on 22.

Customize & Copy →
Production 15 min

Go or Rust single-binary systemd sandbox

Systemd & Agents · systemd

A dynamic-user unit with a read-only filesystem, a private tmp, and a graceful stop. The binary listens on localhost.

Customize & Copy →
Production 15 min

Grafana and Prometheus localhost bind

Docker & Databases · Grafana / Prometheus

Publishes Grafana and Prometheus on localhost so the dashboards and the metrics scrape endpoint are not a public login.

Customize & Copy →
Production 20 min

Hardened multi-stage distroless Dockerfile

Docker & Databases · Docker

Builds a static binary in a builder stage and copies it into a distroless nonroot image with no shell and no package manager.

Customize & Copy →
Beginner 5 min

Hide the PHP version header

Laravel & PHP · Linux

Stages expose_php = Off. Hiding the header is not a patch. Upgrade PHP as well.

Customize & Copy →
Production 15 min

InfluxDB on localhost

Docker & Databases · Docker

Publishes InfluxDB on 127.0.0.1. Replace the password before the first start.

Customize & Copy →
Production 15 min

Jupyter on localhost

Docker & Databases · Docker

Publishes Jupyter on 127.0.0.1. The start script refuses to run while the token is change-me.

Customize & Copy →
Production 15 min

Kafka on localhost

Docker & Databases · Docker

Publishes Kafka on 127.0.0.1. The controller port is not published on the host. This is a single-node broker.

Customize & Copy →
Production 15 min

Langflow on localhost

Docker & Databases · Docker

Publishes Langflow on 127.0.0.1. Use 1.9.0 or later: versions up to 1.8.1 have an exploited code-injection flaw (CVE-2026-33017). A public 7860 is an admin API.

Customize & Copy →
Beginner 5 min

Laravel debug audit

Laravel & PHP · Linux

Prints APP_DEBUG and APP_ENV from the environment file without sending the file anywhere.

Customize & Copy →
Production 30 min

Laravel multi-stage hardened Docker Compose

Laravel & PHP · Docker

A production compose file for PHP-FPM as UID 10001, Nginx, Redis, and a Horizon worker. Published ports stay on localhost and every service drops new privileges.

Customize & Copy →
Production 30 min

Laravel Octane with FrankenPHP

Laravel & PHP · FrankenPHP / Octane

Runs Octane under systemd with a 500-request worker recycle, proxies it through Nginx, and turns on OPcache JIT for the CLI that serves Octane.

Customize & Copy →
Production 15 min

Laravel queue worker

Laravel & PHP · systemd

Stages a queue worker that restarts after artisan queue:restart. It does not start the worker.

Customize & Copy →
Production 15 min

Laravel scheduler timer

Laravel & PHP · systemd

Stages a systemd timer that runs schedule:run as the app user. It does not enable the timer.

Customize & Copy →
Production 25 min

LiteLLM gateway production hardening

AI & LLMs · LiteLLM

Binds the gateway to localhost, reads the master key from a mode 600 file, sets a daily budget, and turns message logging off so prompts and sk- keys are not written to the proxy log.

Customize & Copy →
Beginner 10 min

Logrotate and journald disk guard

Systemd & Agents · systemd

Caps journald at 200 MB and rotates Nginx, Docker, and Laravel logs daily so a quiet host does not fill the disk.

Customize & Copy →
Beginner 10 min

Meilisearch localhost bind and master key

Docker & Databases · Meilisearch

Binds Meilisearch to 127.0.0.1 and refuses to start while the master key is still the placeholder.

Customize & Copy →
Beginner 10 min

Memcached localhost bind

Docker & Databases · Memcached

Binds Memcached to 127.0.0.1 and turns UDP off. The cache protocol does not authenticate.

Customize & Copy →
Production 25 min

MinIO object storage behind Nginx TLS

Docker & Databases · MinIO / Nginx

Keeps the API and console on localhost and publishes them through Nginx on 443. Buckets stay private until a policy says otherwise.

Customize & Copy →
Production 20 min

MongoDB 8 production hardening

Docker & Databases · MongoDB 8

Binds MongoDB to localhost, turns authorization on, and blocks 27017 when UFW is already active. The HTTP status interface is left unset because current mongod builds do not expose it.

Customize & Copy →
Beginner 10 min

Multi-domain TLS and security header audit

Reverse Proxy & SSL · openssl / curl

Reads TLS version, certificate days remaining, HSTS, CSP, and X-Frame-Options for each domain in a list. It does not change DNS or server config. The bundle does not run it.

Customize & Copy →
Production 25 min

MySQL 8.4 and MariaDB 11 production hardening

Docker & Databases · MySQL / MariaDB

Binds the server to localhost, disables LOAD DATA LOCAL, requires TLS for TCP clients, and rotates mariabackup snapshots.

Customize & Copy →
Production 10 min

MySQL local_infile off

Docker & Databases · MySQL / MariaDB

Stages local_infile = 0 and a localhost bind. It does not restart the database.

Customize & Copy →
Production 15 min

NATS on localhost

Docker & Databases · Docker

Publishes NATS on 127.0.0.1. Add accounts before any other host is allowed to connect.

Customize & Copy →
Production 10 min

Next.js bound for a local proxy

Node.js & Next.js · Node.js

Stages a systemd snippet that listens on 127.0.0.1 so Nginx is the public server.

Customize & Copy →
Beginner 5 min

Nginx client body limit

Reverse Proxy & SSL · Nginx

Stages a client_max_body_size so anonymous clients cannot upload huge bodies by default.

Customize & Copy →
Beginner 10 min

Nginx deny dotfiles

Laravel & PHP · Nginx

Stages a server snippet that denies requests for dotfiles such as .env and .git.

Customize & Copy →
Beginner 5 min

Nginx hide version

Reverse Proxy & SSL · Nginx

Stages server_tokens off. Hiding the version is not a patch.

Customize & Copy →
Production 15 min

Nginx login rate limit

Reverse Proxy & SSL · Nginx

Stages a request limit for login paths. It does not block SSH.

Customize & Copy →
Beginner 5 min

Node env file mode 600

Node.js & Next.js · Node.js

Prints the mode of the env file and stages a note. It does not rewrite secrets.

Customize & Copy →
Beginner 5 min

Node inspector closed

Node.js & Next.js · Node.js

Checks whether anything is listening on the Node inspector port.

Customize & Copy →
Production 15 min

Node systemd user unit

Node.js & Next.js · systemd

Stages a Node service that runs as a dedicated user with NoNewPrivileges.

Customize & Copy →
Beginner 10 min

npm ci from the lockfile

Node.js & Next.js · Node.js

Stages an install that uses npm ci so production matches the lockfile.

Customize & Copy →
Production 15 min

Open WebUI on localhost

Docker & Databases · Docker

Publishes Open WebUI on 127.0.0.1. Point it at Ollama on 127.0.0.1:11434 from the container network you intend, not at a public address.

Customize & Copy →
Production 15 min

PgBouncer on localhost

Docker & Databases · Docker

Publishes PgBouncer on 127.0.0.1. The upstream Postgres URL in the file points at the host loopback. Replace change-me before you start it.

Customize & Copy →
Beginner 10 min

PHP session cookie flags

Laravel & PHP · Linux

Stages Secure, HttpOnly, and SameSite for PHP sessions.

Customize & Copy →
Production 20 min

Postfix send-only SMTP relay

Systemd & Agents · Postfix

Listens on loopback only and relays through an authenticated smarthost such as SES, Resend, or Brevo. The bundle writes the files and does not reload a running mail server.

Customize & Copy →
Production 10 min

PostgreSQL listen localhost

Docker & Databases · PostgreSQL 17

Stages listen_addresses and a SCRAM reminder. It does not rewrite a live pg_hba.conf.

Customize & Copy →
Production 25 min

Python FastAPI or Django production stack

Systemd & Agents · Gunicorn / Nginx

A virtualenv, a non-root systemd service, Gunicorn bound to localhost, and Nginx forwarding the original client address.

Customize & Copy →
Production 25 min

Qdrant and pgvector isolation

AI & LLMs · Qdrant / PostgreSQL

Keeps Qdrant on localhost with an API key, terminates TLS at Nginx, and creates the pgvector extension on a localhost PostgreSQL. Snapshots are a cron script you run yourself.

Customize & Copy →
Production 15 min

RabbitMQ localhost bind

Docker & Databases · RabbitMQ

Keeps AMQP and the management UI on localhost. The default guest user is limited to loopback by RabbitMQ itself.

Customize & Copy →
Production 15 min

Ray dashboard on localhost

AI & LLMs · Local AI

Stages a Ray start command that binds the dashboard to 127.0.0.1. The Jobs API does not authenticate by itself.

Customize & Copy →
Production 15 min

Redis ACL file

Docker & Databases · Redis / Valkey

Stages an ACL that disables the default user and adds an application user. It does not restart Redis.

Customize & Copy →
Production 20 min

Redis or Valkey production security and persistence

Docker & Databases · Redis / Valkey

Binds Redis to loopback, keeps protected mode, adds an ACL user, disables FLUSHALL, and turns on AOF plus RDB. The overcommit sysctl is set for the background save.

Customize & Copy →
Beginner 10 min

security.txt

Reverse Proxy & SSL · Nginx

Stages a security.txt with a contact address you replace. It does not harden the server by itself.

Customize & Copy →
Production 25 min

Self-hosted n8n hardened production setup

AI & LLMs · n8n / Nginx

Keeps n8n on localhost, puts basic auth in front of the UI, rate-limits webhooks at Nginx, and excludes the execute-command node. Public signup stays off because this file does not enable open registration.

Customize & Copy →
Production 20 min

Separate PHP-FPM pool

Laravel & PHP · Linux

Stages a pool that runs as its own user and listens on a socket. It does not reload PHP.

Customize & Copy →
Production 10 min

Shared memory noexec

Server Hardening · Linux

Stages an fstab line so /dev/shm is mounted noexec,nosuid,nodev. Apply it from a console session.

Customize & Copy →
Beginner 5 min

SSH login banner

Server Hardening · Linux

Stages a short authorized-use banner. It does not change authentication.

Customize & Copy →
Beginner 10 min

SSH session limits

Server Hardening · Linux

Stages idle and authentication limits. It does not change password login or root login.

Customize & Copy →
Zero-Trust 20 min

Staged nftables allow for SSH and web

Server Hardening · Linux

Stages an nftables input policy that still accepts SSH on 22 plus HTTP and HTTPS. It is not loaded.

Customize & Copy →
Beginner 15 min

Static site and SPA Nginx template

Reverse Proxy & SSL · Nginx

Serves an Astro or React build with gzip, a long cache on hashed assets, an SPA fallback, and a strict content security policy.

Customize & Copy →
Beginner 10 min

sudo command logging

Server Hardening · Linux

Stages a sudoers drop-in that logs every sudo command. It does not grant NOPASSWD.

Customize & Copy →
Beginner 10 min

Swapfile and OOM protection for a small VPS

Server Hardening · Linux

Creates a 2 GB swapfile with mode 600 when one is missing, and sets swappiness to 10 and vfs_cache_pressure to 50. Running it again does not recreate the file.

Customize & Copy →
Production 10 min

Sysctl network baseline

Server Hardening · Linux

Stages kernel network settings that drop redirects and ignore source-routed packets. It does not change SSH.

Customize & Copy →
Production 15 min

systemd credential file

Systemd & Agents · systemd

Stages a pattern that loads a mode 600 file as a credential instead of putting the secret in the unit.

Customize & Copy →
Beginner 10 min

systemd memory cap

Systemd & Agents · systemd

Stages a MemoryMax so one service cannot consume the whole VPS. Pick the number for this host.

Customize & Copy →
Beginner 10 min

systemd private tmp

Systemd & Agents · systemd

Stages PrivateTmp so a service cannot read another service temporary files.

Customize & Copy →
Production 15 min

systemd sandbox defaults

Systemd & Agents · systemd

Stages a drop-in with NoNewPrivileges, PrivateTmp, and ProtectSystem. Merge it into a unit you have tested.

Customize & Copy →
Production 30 min

Traefik v3 Docker reverse proxy, certificates, and middleware

Reverse Proxy & SSL · Traefik / Docker

Runs Traefik against a filtered Docker socket proxy, requests certificates for the site, adds secure headers, and puts basic auth plus an IP allowlist on the dashboard.

Customize & Copy →
Beginner 15 min

Trivy image scan in GitHub Actions

Docker & Databases · GitHub Actions

Builds the image in CI and fails the job when Trivy reports a critical or high finding. The scan does not deploy.

Customize & Copy →
Production 15 min

Typesense on localhost

Docker & Databases · Docker

Publishes Typesense on 127.0.0.1. Replace the API key before you start it.

Customize & Copy →
Beginner 10 min

Unattended security updates

Server Hardening · Linux

Stages unattended-upgrades so security updates install without a manual apt run. It does not enable the timer until you review the file.

Customize & Copy →
Production 10 min

Unused filesystem modules

Server Hardening · Linux

Stages a modprobe block for filesystem types a VPS does not mount. It does not unload modules that are already in use.

Customize & Copy →
Production 15 min

Vaultwarden on localhost

Docker & Databases · Docker

Publishes Vaultwarden on 127.0.0.1 and leaves public signups off.

Customize & Copy →
Production 15 min

vLLM on localhost

AI & LLMs · Local AI

Stages a vLLM server bound to 127.0.0.1. Put the PortGate AI proxy in front if you want caps.

Customize & Copy →
Zero-Trust 25 min

WireGuard private mesh and bastion access

Server Hardening · WireGuard

Creates a 10.100.0.0/24 interface for admin access. Moving sshd onto that interface is a separate script so a failed handshake cannot remove public SSH.

Customize & Copy →
Beginner 5 min

WordPress application passwords off

WordPress · Linux

Stages a filter that disables application passwords. Useful when the site does not use the REST API with app passwords.

Customize & Copy →
Beginner 10 min

WordPress core checksum check

WordPress · Linux

Runs wp core verify-checksums when WP-CLI is installed. It does not update core.

Customize & Copy →
Beginner 5 min

WordPress disallow file edits

WordPress · Linux

Stages the constants that turn off the theme and plugin editor and in-dashboard installs.

Customize & Copy →
Beginner 10 min

WordPress file permissions check

WordPress · Linux

Prints permissions and refuses to chmod the tree. World-writable PHP is the thing to fix by hand.

Customize & Copy →
Beginner 10 min

WordPress xmlrpc off

WordPress · Nginx

Stages an Nginx deny for xmlrpc.php. WordPress itself can also filter the method.

Customize & Copy →
Production 25 min

Zero-downtime GitHub Actions SSH deploy

Systemd & Agents · GitHub Actions

A deploy key restricted to one command, a release directory with an atomic current symlink, and a reload of PHP-FPM or PM2. None of these files are installed into authorized_keys by the bundle.

Customize & Copy →