Networking

MeshCentral Behind a Reverse Proxy – NGINX, HAProxy and TLS Offload

Why proxies need extra care with MeshCentral, and the exact settings that keep agents connected.

Diagram of HAProxy forwarding HTTPS traffic to a MeshCentral server with TLS offloading

MeshCentral can sit behind a reverse proxy such as NGINX, HAProxy, Traefik or Caddy, and many administrators prefer it that way. A proxy lets several web applications share one public address, centralises certificate management and adds a layer of filtering in front of the server. MeshCentral is more particular about proxies than an ordinary website, however, because its agents verify the server's certificate and rely on long-lived WebSocket connections. This article explains why those details matter, how TLS offloading works, which MeshCentral settings to change and how to configure the most common proxies correctly.

Why Use a Reverse Proxy?

A reverse proxy receives connections from browsers and agents and forwards them to MeshCentral running behind it. The reasons for adding one include:

  • Sharing ports. Several services can be published on port 443 of a single address, each selected by hostname.
  • Centralised certificates. One proxy can obtain and renew certificates for every service it fronts.
  • Additional protection. Proxies can rate-limit requests, filter addresses and keep the application server off the public interface.
  • Consistent infrastructure. Organisations that already route everything through a proxy can treat MeshCentral like any other service.

If MeshCentral is the only service on its server, a proxy is optional. MeshCentral can obtain its own Let's Encrypt certificate and serve HTTPS directly, which is simpler.

The Two Things That Make MeshCentral Different

Agents check the certificate

When MeshAgent connects, it verifies that the server holds a specific certificate key. When a proxy terminates TLS, the agent sees the proxy's certificate rather than MeshCentral's own. MeshCentral therefore needs to know which certificate the proxy presents so that it can give agents the correct information. Without this, browsers may work perfectly while agents refuse to connect, a combination that puzzles many administrators.

Connections are long-lived WebSockets

Agents hold a WebSocket connection open permanently, and remote desktop, terminal and file sessions use WebSockets too. A proxy must pass the WebSocket upgrade through correctly and must not close connections that appear idle after a short timeout.

Understanding TLS Offloading

In a typical proxy arrangement, the proxy handles TLS on port 443 and forwards plain HTTP to MeshCentral on an internal port, a pattern known as TLS offloading. MeshCentral must then be configured to accept unencrypted connections from the proxy and to behave as though it were serving HTTPS on port 443.

The key settings in the settings section of config.json are:

{
  "settings": {
    "cert": "mesh.yourdomain.example",
    "port": 4430,
    "aliasPort": 443,
    "redirPort": 800,
    "agentPong": 300,
    "tlsOffload": "127.0.0.1",
    "trustedProxy": "127.0.0.1",
    "certUrl": "https://127.0.0.1:443/"
  }
}
  • port is the internal port on which MeshCentral listens for the proxy.
  • aliasPort tells MeshCentral which port users and agents actually connect to, so that links and installers use 443.
  • redirPort moves MeshCentral's own HTTP listener to an unused internal port, because the proxy now owns port 80.
  • agentPong makes the server send regular keep-alive messages to agents, which stops proxies from treating the connections as idle.
  • tlsOffload tells MeshCentral that TLS is handled by the proxy at the given address.
  • trustedProxy allows MeshCentral to read the original client address from forwarded headers, so that logs and IP restrictions reflect real users rather than the proxy.
  • certUrl tells MeshCentral where to read the certificate the proxy presents, which is explained in the next section.

Giving MeshCentral the Proxy's Certificate

MeshCentral must learn the certificate the proxy presents so that it can tell agents what to trust. There are two common approaches.

  • The certUrl setting. Point MeshCentral at the proxy's HTTPS address, and it will connect, read the certificate and use it for agent verification. This is convenient and follows automatic renewals.
  • Copying the certificate. Place the proxy's public certificate in the data folder with the file name MeshCentral expects for its web certificate.

When certificates are renewed with the same key, agents continue to connect. When the key changes, MeshCentral must learn the new certificate, which certUrl handles automatically.

If browsers work but agents stay offline after adding a proxy, the certificate configuration is the first place to look.

Configuring NGINX

NGINX is the most widely used reverse proxy for MeshCentral. A server block needs to forward requests, upgrade WebSocket connections and keep long sessions open.

server {
    listen 443 ssl http2;
    server_name mesh.yourdomain.example;

    ssl_certificate     /etc/ssl/mesh/fullchain.pem;
    ssl_certificate_key /etc/ssl/mesh/privkey.pem;

    proxy_send_timeout 330s;
    proxy_read_timeout 330s;

    location / {
        proxy_pass http://127.0.0.1:4430/;
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
        proxy_set_header Host $host;
        proxy_set_header X-Forwarded-Host $host:$server_port;
        proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header X-Forwarded-Proto $scheme;
    }
}

The timeouts are longer than the 300-second agentPong interval set earlier so that idle agent connections are not dropped. Add a separate server block on port 80 that redirects to HTTPS and serves certificate challenges if your certificate tool needs them.

When several hostnames lead to the same server, each must be covered by the proxy's certificate and forwarded with the correct Host header, otherwise MeshCentral cannot work out which domain the request belongs to.

Configuring HAProxy

HAProxy is popular for its performance and fine-grained control. Two arrangements are possible.

TLS termination at HAProxy

HAProxy decrypts traffic and forwards plain HTTP to MeshCentral's internal port, adding forwarding headers. MeshCentral is configured with tlsOffload and certUrl as described above. HAProxy's timeouts for clients, servers and tunnels must be long enough to hold WebSocket connections open.

TCP passthrough

Alternatively, HAProxy can forward the encrypted TCP stream untouched, selecting the backend by the hostname in the TLS handshake. MeshCentral then handles TLS itself with its own certificate, and agents verify it directly. This avoids certificate coordination entirely, at the cost of the proxy being unable to inspect or modify requests.

Traefik and Caddy

Both Traefik and Caddy obtain certificates automatically and support WebSockets without extra configuration in most cases. The MeshCentral side remains the same: an internal port, aliasPort set to 443, tlsOffload and trustedProxy pointing at the proxy, and a certUrl so MeshCentral learns the proxy's certificate. In container environments, place the proxy and MeshCentral on the same private network and avoid publishing MeshCentral's internal port to the host.

Intel AMT and the Proxy

Intel AMT client-initiated remote access uses its own TLS connection on port 4433, which should not pass through an HTTP reverse proxy. If you manage such devices, publish port 4433 directly to MeshCentral or forward it as plain TCP.

Testing the Configuration

After making changes, test methodically.

  • Restart MeshCentral and check its startup messages for the expected ports and offload mode.
  • Open the dashboard through the proxy and confirm there are no certificate warnings.
  • Install an agent on a test machine and confirm it connects and stays connected.
  • Open a remote desktop session and leave it idle for several minutes to check that it is not dropped.
  • Review the event log to confirm real client addresses are recorded rather than the proxy's address.

Troubleshooting Proxy Problems

Agents connect but disconnect every minute or so

The proxy is closing idle WebSockets. Increase read and send timeouts beyond MeshCentral's keep-alive interval.

The dashboard loads but sessions never start

WebSocket upgrades are not being forwarded. Check the Upgrade and Connection headers and the HTTP version used towards the backend.

Every login appears to come from 127.0.0.1

MeshCentral is not trusting the proxy's forwarding headers. Set trustedProxy to the proxy's address and make sure the proxy sends X-Forwarded-For.

Links and installers point to the wrong port

Set aliasPort to the public port, normally 443, so that MeshCentral generates correct addresses.

What a Proxy Does and Does Not Protect

A reverse proxy adds useful defences, but it is important to be clear about their limits. A proxy can hide MeshCentral's own listening port from the internet, filter requests by address, apply rate limits to the login page and present a single, well-maintained TLS configuration. It can also log requests in a format your monitoring tools already understand.

What a proxy cannot do is fix weaknesses in the application behind it. If MeshCentral itself has an unpatched vulnerability, requests that exploit it will usually pass through the proxy looking perfectly normal. Weak passwords, missing second factors and over-generous permissions are equally unaffected by the presence of a proxy.

Treat the proxy as one layer among several. Keep MeshCentral updated, enforce strong authentication inside it and use the proxy for what it does well: managing certificates, controlling exposure and adding coarse filtering in front of the server. When the proxy and MeshCentral run on the same machine, bind MeshCentral's internal port to the loopback address so that it cannot be reached directly from the network, bypassing the proxy altogether.

Hosting MeshCentral Under a Path

Some administrators want MeshCentral to appear under a sub-path of an existing website rather than on its own hostname. This is possible but adds complexity, because links, installers and agent connections must all agree on the path. A dedicated subdomain is far simpler and avoids subtle problems, so it is the recommended approach whenever DNS can be changed. If a sub-path is unavoidable, test agent installation, remote desktop and file transfer thoroughly before relying on the setup.

Frequently Asked Questions

No. MeshCentral can serve HTTPS itself, including obtaining Let's Encrypt certificates. A proxy is useful when sharing an address with other services or centralising certificates.

Agents verify the server's certificate. When a proxy terminates TLS, MeshCentral must be given the proxy's certificate through certUrl or by placing it in the data folder.

An internal port, aliasPort set to the public port, tlsOffload and trustedProxy pointing to the proxy, and a way for MeshCentral to learn the proxy's certificate.

Yes. In TCP passthrough mode, MeshCentral handles TLS itself, which avoids certificate coordination.

No. Port 4433 for Intel AMT client-initiated access should reach MeshCentral directly or as plain TCP forwarding.

Longer than MeshCentral's keep-alive interval; several minutes is common, so idle agent connections are not dropped.

Conclusion

MeshCentral works very well behind a reverse proxy once its two special requirements are respected: agents must be able to verify the certificate the proxy presents, and long-lived WebSocket connections must pass through without being cut. Configure the internal port, aliasPort, tlsOffload, trustedProxy and certUrl, set generous proxy timeouts and test with a real agent rather than only a browser. With those pieces in place, the proxy becomes a reliable, secure front door for the whole platform.