[Bug] Terminal fails with "Auth server unreachable" (1011) when Proxy Bind Address is a specific IP
Describe the bug
With reverse proxy mode enabled and Proxy Bind Address set to a specific LAN IP, the LXC terminal fails immediately with "Auth server unreachable" and close code 1011. The VNC console works.
The SSH/terminal websocket server is started as a subprocess with (pegaprox/api/vms.py):
main_port = port - 2
env['PEGAPROX_URL'] = f"https://127.0.0.1:{main_port}" if ssl_cert else f"http://127.0.0.1:{main_port}"
It validates every session against PEGAPROX_URL/api/ws/token/validate. With a custom bind address, the main app only listens on that IP, not on 127.0.0.1, so the validation request is refused. The VNC path is not affected because it validates in-process.
Steps to Reproduce
- Settings → Server: enable Behind a reverse proxy, set Proxy Bind Address to the LAN IP of the host (for example
192.168.0.234), save and restart. - Confirm that the main app listens only on that IP (
ss -tlnpshows192.168.0.234:5000). - Open the terminal of any LXC container.
Expected behavior
The terminal opens, as it does when the main app listens on all interfaces.
Environment
- PegaProx Version: 1.2.0 (Debian package 1.2.0-1)
- Installation Method: Other: APT repository packages.gyptazy.com, Debian trixie
- OS: Debian 13 (trixie), unprivileged LXC on Proxmox VE 9.2
- Browser: Chrome
- Behind Reverse Proxy? Traefik v3.6 (via Pangolin), path-based routing to ports 5000/5001/5002
- UI?
Logs
# Browser terminal
Conectando a WebSocket...
Auth server unreachable
Session ended (code 1011 — auth)
# Environment of the SSH WS subprocess
SSH_WS_HOST=192.168.0.234
SSH_WS_PORT=5002
PEGAPROX_URL=http://127.0.0.1:5000
# Main app bound to the custom address
LISTEN 0 128 192.168.0.234:5000 0.0.0.0:* users:(("python3",...))
$ curl -s -o /dev/null -w '%{http_code}' http://127.0.0.1:5000/api/ws/token/validate
000
Screenshots
N/A
Checklist
- [ ] I have searched existing issues to make sure this is not a duplicate
- [ ] I am using the latest version of PegaProx
- [ ] I've put enough in here that someone can start on it without asking me three questions first
- [ ] I understand PegaProx is maintained by volunteers in their free time. Nobody is on call, and writing URGENT doesn't get anyone out of bed 🪄
Workaround: set Proxy Bind Address to 0.0.0.0 and restrict access to ports 5000–5002 with a host firewall.
Suggested fix: build PEGAPROX_URL from the actual bind address, or always keep a loopback listener for internal validation. Deriving main_port as port - 2 is also fragile if the ports are ever customised.
Also confirmed. env['PEGAPROX_URL'] is built as https://127.0.0.1:{main_port} unconditionally when the terminal subprocess is spawned, and the subprocess then validates every session against that address. Bind the app to a single LAN IP and there is nothing on loopback to answer, so the validate call is refused and you get the 1011.
Your read on why VNC survives is right too, that leg validates in-process and never leaves the machine.
The bind address is already in settings, so the subprocess should be told the address the app actually listens on rather than assuming loopback. Assigned to myself with #955 and #956, they are all in the same handler area and I would rather touch it once.
Marcus
Confirmed and fixed on Testing. Your diagnosis is complete and the fix is the one you implied.
The subprocess URL is no longer a literal 127.0.0.1. The app now records the address it actually bound to, and the subprocess is pointed at that - 127.0.0.1 only when the bind address is a wildcard (empty, 0.0.0.0, ::), which is the case where loopback is genuinely reachable. IPv6 literals get their brackets. There is a test that binds to a specific address and asserts the subprocess is handed that address and not loopback.
Worth saying out loud, because it was not obvious from the outside: the VNC path was unaffected only by luck, not by design - it validates in-process, as you noticed. So this was one path out of two, not a general property.
Thanks for the ss -tlnp output and the curl returning 000. That turned a vague "terminal is broken behind a proxy" into a one-line cause.
The terminal subprocess now validates sessions against the address the app actually bound to, and uses 127.0.0.1 only for a wildcard bind (empty, 0.0.0.0 or ::), with brackets for IPv6 literals. With Proxy Bind Address set to a single LAN IP the terminal opens again instead of closing with 1011. This ships in 1.3.0.
If PegaProx saves you some time, a small contribution at https://opencollective.com/pegaprox keeps it going.
Marcus