Self-hosting

Why my hosting panel has no public login page

Every hosting panel I've used had a login page on the public internet. Type the address, get a username and password box. It's convenient, and it's the first thing an attacker looks for.

When I built my own panel, I decided it wouldn't have one.

What I was trying to do

A hosting panel can deploy sites, restart services and read logs. Whoever gets into it owns everything on the server. So the goal was simple: make the panel something a stranger can't even find, let alone guess a password for.

Why not just a strong password?

A public login page with a good password and 2FA is not reckless. Plenty of people run that. But it leaves three problems:

  • It gets hammered anyway. My server's logs show a steady stream of requests for admin and login pages belonging to software I don't even run. Bots don't check first. They just try.
  • The login page is code, and code has bugs. A password protects the account. It does nothing if the flaw is in the page itself.
  • I'm the only user. A public login exists so that anyone, anywhere can sign in. I don't need anyone, anywhere. I need me.

That last one settled it. I was about to accept a risk in exchange for a feature I'd never use.

What I did instead

The panel only listens on a private network that my own devices are part of. From the public internet there is no page, no port and no error message. There is nothing there to attack.

Being on the private network is not enough to get in, though. The panel still asks for:

  1. A password.
  2. A 2FA code from my phone.

So there are two separate locks. Someone would need a device on my private network and my password and my phone. If one of my devices were ever stolen or infected, the panel is still not open to it.

A few smaller things sit behind that:

  • Repeated wrong passwords lock sign-in for a while.
  • Every sign-in and every action goes into an audit log I can read in the panel.
  • One-time recovery codes exist in case I lose the phone.
  • Remote shell access to the server follows the same rule: private network only.

What broke

I locked down a browser header and broke every form. While tightening the panel, I told it to send no referrer information at all. Chrome responded by labelling every form submission as coming from nowhere, and my own cross-site check rejected all of them. It passed my command-line tests and failed the first time I clicked a button. Now I test forms in a real browser.

Private publishing collided with the public web server. I first published the panel on the same port my web server uses for HTTPS. That took my sites down the first time the web server restarted. The panel has its own port now.

What worked

The piece worth copying, if you run anything in Docker: bind admin tools to the local machine, not to every address.

ports:
  - "127.0.0.1:<port>:<port>"   # only this machine can reach it
# not "<port>:<port>", which listens on every address the server has

That matters more than it looks. Docker publishes ports with its own firewall rules, so a container listening on every address can be reachable from the internet even when your firewall says the port is closed. Bound to the local machine, it's only reachable through whatever private route you set up in front of it.

What it costs

This isn't free.

  • No signing in from a borrowed computer. If the device isn't on my private network, the panel doesn't exist for it.
  • The private network is now something I depend on. If it has a bad day, I can't reach the panel. The sites keep running, and my hosting provider's console is still there as a way back in.
  • It doesn't scale to a team. Every person would need a device on the network. For one admin that's fine. For ten it would be a chore.

For a server with one admin, I'll take those trades. The best outcome for a login page is that nobody ever gets to try it.