Home / Articles / Home lab operations
Home lab operations · English edition
Home Lab Reverse Proxy and TLS Hardening Without Exposing Admin Ports
Most home labs do not get compromised because someone picked the wrong cipher suite. They get compromised because a management panel stayed reachable on a high port, kept a default credential, and nobody looked at it again. This article describes the sequence I use: decide the port map first, put one reverse proxy in front of the services that genuinely need to be public, keep every admin surface off the internet, and then verify the result from outside the network instead of from the LAN.
The problem: one public IP, six admin panels
A typical self-hosted setup grows by accretion. A dashboard on 8080, a media server on 8096, a download client on 8112, a hypervisor console on 8006, a storage appliance on 5001, and an SSH daemon on 22. Each one was reached directly while it was being set up, and each one still answers on the same public address months later. The firewall rule that opened it has usually been forgotten, because it was made in a router UI, not in a config file anyone reads.
The important property of that setup is not that any single service is weak. It is that the number of doors is proportional to the number of things that have to be perfectly configured. Every panel keeps its own authentication, its own session handling, its own update cycle, and its own idea of what a strong password is. A reverse proxy does not fix that; it reduces the number of doors to one, and then the authentication and TLS work happens in a single place you can review in a diff.
There is a second failure that is easy to miss: a proxy in front of an admin panel is not the same as an admin panel that is off the internet. If the upstream port is still forwarded, the proxy is decoration. The rule this article is built around is narrow and boring: the only inbound port from the internet is 443 (plus 80 if your ACME client needs HTTP-01), and everything administrative is reachable only from a private network.
Step 1 — write the port map before touching a config
Before changing anything, write down what currently listens on the box and who needs to reach it. Two commands give you most of the picture on a Linux host:
# Listening sockets with the owning process
sudo ss -lntup
# Which of those are reachable from outside the host firewall
sudo nft list ruleset 2>/dev/null || sudo iptables -S
Then classify each service into one of three groups. I use the same three columns every time, because the classification is what the firewall and proxy config are generated from.
| Class | Examples | Where it belongs |
|---|---|---|
| Public — meant to be read by anyone | Static site, blog, public API endpoint | 443 on the proxy, no client certificate. This is the only class that gets a public DNS record. |
| Private-but-remote — you need it while travelling | File sync, media server, notes, photo library | 443 on the proxy with an authentication layer you control (mTLS, or the app's own login plus rate limiting), or better: inside the VPN only. |
| Admin — changes the machine or the network | Hypervisor console, container manager, storage appliance UI, router, SSH, database | Never on a forwarded port. VPN, WireGuard, Tailscale, or an SSH tunnel. If a vendor insists on a web UI, bind it to loopback and reach it through the tunnel. |
Step 2 — pick one of two topologies
There are two sane shapes, and they differ in what a DNS lookup reveals and what breaks when the VPN is down.
Topology A — one public entry point, admin behind a tunnel. A single wildcard or multi-name certificate covers files.example.com and www.example.com. Every admin panel is reachable only through WireGuard or an SSH local forward, so admin.example.com either does not resolve publicly or resolves to nothing. This is the simplest to reason about and the one I recommend for a first pass.
Topology B — split-horizon DNS, admin names resolve only internally. An internal resolver returns RFC1918 addresses for panel.lan.example.com; the public zone either omits the name or returns a dead address. This keeps short, memorable names and lets the proxy serve both worlds. The cost is that you now run and maintain a resolver, and a misconfigured public zone can publish the admin name by accident.
| Topology A: tunnel for admin | Topology B: split-horizon DNS | |
|---|---|---|
| Public names | Only the services you intend to publish | Same, but a misconfigured zone can leak admin names |
| Certificate scope | Small; one cert for published names | Needs either a wildcard or per-name certs for internal names |
| Failure when away | Admin unavailable until the tunnel is up — which is the point | Admin reachable if the resolver and proxy are both correct |
| Things to maintain | Tunnel config, one proxy config | Tunnel or not, plus internal DNS, plus one proxy config |
| Best for | Home labs, single operator | Labs with several users who should not install a VPN client |
Step 3 — the proxy configuration (Caddy, then nginx)
Both examples below assume the proxy terminates TLS and the upstream services listen on loopback or on a private interface. The upstreams must not be reachable from the internet; if they are, the proxy adds nothing.
Caddy
Caddy obtains and renews certificates automatically and redirects HTTP to HTTPS by default, which removes the most common renewal failure: a redirect rule that also catches the ACME challenge path.
{
email admin@example.com
}
www.example.com {
root * /srv/www
file_server
encode zstd gzip
header {
Strict-Transport-Security "max-age=15552000"
X-Content-Type-Options "nosniff"
Referrer-Policy "strict-origin-when-cross-origin"
-Server
}
}
files.example.com {
# Authenticate at the proxy, not only in the app
basic_auth {
operator $2a$14$REPLACE_WITH_HASH_FROM_caddy_hash-password
}
reverse_proxy 127.0.0.1:8384 {
header_up X-Forwarded-Proto {scheme}
}
log {
output file /var/log/caddy/files.log
}
}
# A name that exists only to be unhelpful from the internet
admin.example.com {
respond 404
}
Two details in that config matter more than they look. basic_auth uses a bcrypt hash generated by caddy hash-password, not a plaintext comparison, and the -Server directive removes the version banner. The catch-all respond 404 block is deliberate: if a name leaks into a certificate transparency log, a request to it gets the same answer as a typo, not a login form.
nginx
With nginx you own renewal. Certbot's --nginx and --webroot modes both need port 80 reachable at renewal time, so an HTTP-to-HTTPS redirect must exclude /.well-known/acme-challenge/.
server {
listen 80;
server_name www.example.com;
location /.well-known/acme-challenge/ {
root /var/www/acme;
}
location / {
return 301 https://$host$request_uri;
}
}
server {
listen 443 ssl;
http2 on;
server_name www.example.com;
ssl_certificate /etc/letsencrypt/live/www.example.com/fullchain.pem;
ssl_certificate_key /etc/letsencrypt/live/www.example.com/privkey.pem;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;
ssl_session_cache shared:SSL:10m;
ssl_session_timeout 1d;
add_header Strict-Transport-Security "max-age=15552000" always;
add_header X-Content-Type-Options "nosniff" always;
server_tokens off;
location / {
root /srv/www;
index index.html;
try_files $uri $uri/ =404;
}
}
If both a bare name and www are used, the certificate must contain both. A cert with a single SAN is the most common cause of "the site is fine, but the www address shows a warning" — the proxy is not the problem, the name list is. Let's Encrypt allows up to 100 names per certificate, so there is little reason to ship a cert that covers only half of the names you actually use.
Step 4 — TLS settings that actually matter
Most TLS checklists are longer than they need to be. In practice these five items cover almost everything that a review will find:
- Protocol floor. Allow TLS 1.2 and 1.3 only. TLS 1.0 and 1.1 are deprecated by RFC 8996 and fail modern scanners.
- Renewal path. Know which ACME challenge you use and what it needs: HTTP-01 needs inbound port 80 reachable by the CA, TLS-ALPN-01 needs 443, DNS-01 needs only API access to your DNS provider. DNS-01 is the quiet choice when you cannot keep 80 open.
- Name coverage. Every hostname you serve must be in the certificate. Check with the command in the verification section, not from memory.
- Redirect direction. HTTP redirects to HTTPS, and the redirect does not swallow the challenge path.
- HSTS only after the names are consistent. Setting a long
max-ageon a domain whose subdomains still speak plain HTTP will lock users out of those subdomains. Start with a short value, confirm nothing breaks, then raise it.
Cipher ordering is a much smaller lever than it used to be. With TLS 1.3 the suite list is short and safe by design; for TLS 1.2, a modern default set (ECDHE with AES-GCM or ChaCha20-Poly1305) is what every current server profile uses. Copy a maintained profile rather than hand-tuning, and revisit it when the profile is updated.
Step 5 — stack access control instead of trusting one layer
For the "private-but-remote" class, one authentication check is rarely enough, because the interesting failures are the ones where the app's login is bypassed by a version-specific bug, or where a restore brings back an old admin account nobody remembers. Two layers that fail differently are worth more than one very strict layer.
- Client certificates (mTLS). The proxy requires a certificate signed by your own CA. A stolen password is useless without the key file. Operational cost: you must distribute and renew client certs, and revoking one means maintaining a CRL or an allowlist of serials.
- Proxy-level credentials. Basic or form auth on the proxy with a bcrypt/argon2 hash. Cheap, effective against scanners, and visible in the proxy log under a separate field so you can tell "blocked at the door" from "logged into the app".
- Source allowlists. Useful only when your source addresses are stable. With mobile networks they are not, and an allowlist that is bypassed through a misread
X-Forwarded-Foris worse than none — see the next section. - Rate limiting. A per-IP limit on the login path turns a credential-stuffing run into noise in your log. Set it per path, not globally, so a large file download does not trigger it.
- Session policy. Short idle timeout on the app, and a proxy timeout so an idle browser tab does not hold a session open for days.
Step 6 — headers and the mistakes that leak past the proxy
These are the issues I see most often after a proxy has been in place for a while and nobody has re-read the config.
| Symptom | Cause | Fix |
|---|---|---|
App generates http:// links and login loops |
Upstream never learns the original scheme | Send X-Forwarded-Proto and X-Forwarded-For; set the app's trusted-proxy list to the proxy's address only |
| Allowlist can be bypassed | App trusts a client-supplied X-Forwarded-For header |
Strip or overwrite the header at the proxy; never append to a client value |
| Admin path reachable once a service is published | One reverse_proxy block for the whole site including /admin |
Deny the admin path at the proxy and return 404, not 403 — a 403 confirms the path exists |
| Upstream version disclosed | Upstream's own Server/X-Powered-By headers pass through |
Hide them at the proxy and, where possible, in the app |
| Websocket or long-poll features break | Proxy buffers the response or drops the upgrade header | Enable upgrade handling for that specific path, not globally |
| Proxy health check passes while the app is broken | Health check hits a static file, not the app's own endpoint | Probe a path that exercises the app's routing and database connection |
A path-level denial in nginx, for the case where a service publishes both a public and an administrative path under the same name:
location ^~ /admin/ {
return 404;
}
location / {
proxy_pass http://127.0.0.1:8080;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
Note X-Forwarded-For $remote_addr rather than $proxy_add_x_forwarded_for. The latter appends to whatever the client sent, which is exactly the header an attacker wants you to trust.
Step 7 — verify from outside, not from the LAN
This is the step people skip. From inside the network your requests may take a local path that never touches the public rule you are trying to test, so a "works for me" check proves very little. Run these from a phone hotspot, a VPS, or any network that is not the one you are configuring.
# 1. What does the CA actually serve for each name?
openssl s_client -connect www.example.com:443 -servername www.example.com \
</dev/null 2>/dev/null | openssl x509 -noout -subject -dates -ext subjectAltName
# 2. Is the redirect correct, and does it preserve the challenge path?
curl -sSI http://www.example.com/ | head -5
curl -sS -o /dev/null -w '%{http_code}\n' http://www.example.com/.well-known/acme-challenge/test
# 3. Which ports answer from the internet? (your own asset only)
nmap -Pn -p 22,80,443,5000,5001,8080,8443 example.com
# 4. Protocol and cipher posture
testssl.sh --quiet --protocols --headers https://www.example.com
Expected results: step 1 lists every name you serve and an expiry date far enough out that a failed renewal would still be visible; step 2 returns a 301 to HTTPS and a non-404 answer on the challenge path; step 3 shows 80 and 443 open and everything else filtered; step 4 shows no TLS 1.0/1.1 and no HSTS on a name that is not ready for it.
Two more checks that are easy to add and catch real problems: request an admin hostname that should not exist and confirm it returns the same answer as a random name, and read the proxy log for a day to see what is actually being requested. Scanner traffic against paths that were removed two weeks ago is normal; a 200 on such a path means an old rule is still serving something.
Failure modes worth recognising
| What happens months later | Why | Prevention |
|---|---|---|
| Certificate expired silently | HTTP-01 validation blocked by a closed port 80, or a redirect caught the challenge | External expiry monitor with at least 14 days of warning; test renewal with a staging CA |
| A second public port appears | An app opened a port itself through UPnP, or a router rule was added during troubleshooting | Disable UPnP on the router; audit forwarding rules on the same schedule as the TLS check |
| Proxy passes an unauthenticated path | An exclusion rule added for one endpoint later matched more than intended | Keep the config in version control; review the diff after every change |
| Everyone locked out after an HSTS change | max-age raised while a subdomain still served HTTP | Raise gradually; keep a second browser profile that has not seen the header |
| Backup restored an old admin account | Restores are tested for data, not for authentication state | Include an access review in the restore drill |
One-page checklist
- Every listening socket is classified as public, private-but-remote, or admin
- Only 443 (plus 80 for HTTP-01) is forwarded from the internet; nothing else
- Admin panels are bound to loopback or a private interface and reached through a tunnel
- One certificate covers every name actually served, including
www - Renewal path tested end to end, not assumed; external expiry alert in place
- TLS 1.2 minimum, maintained cipher profile, no version banner
- At least two independent authentication layers on anything private-but-remote
X-Forwarded-Foroverwritten at the proxy, not appended- Admin paths return 404 at the proxy rather than 403
- Verification run from outside the network and repeated after every config change