Home About Me

Fixing HestiaCP's Web Terminal Redirect to localhost

The web terminal at https://hostname:8083/_shell/ can fail with a 302 redirect to http://localhost:8083, leaving the shell page blank or stuck. The redirect points at the nginx proxy configuration for HestiaCP: the request reaches the backend without the original Host header, so the terminal service builds its redirect around localhost instead of the public hostname.

The proxy block is defined in /usr/local/hestia/nginx/conf/nginx.conf. The broken version looks like this:

location /_shell/ {
            proxy_pass http://localhost:8083;
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_set_header X-Real-IP $remote_addr;
                       # the Host header is missing
        }

Two things need correcting. First, proxy_pass is pointing at port 8083, which may not be the port the web terminal actually listens on. The correct value is stored as WEB_TERMINAL_PORT in /usr/local/hestia/conf/hestia.conf. Second, the Host header is never forwarded, which is what causes the backend to redirect to localhost.

The corrected block:

location /_shell/ {
            proxy_pass http://localhost:8085;   # Change the port
            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "Upgrade";
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header Host $host;     # Add this line
        }

Replace 8085 with the actual WEB_TERMINAL_PORT value from hestia.conf, and keep the added proxy_set_header Host $host; line.

Once the file is saved, reload nginx so the change takes effect. Rebooting the server is another option and is recommended if a simple reload does not clear the issue. After that, /_shell/ should load against the public hostname instead of redirecting to localhost.