Skip to content
GitHubSupport

Behind a proxy

If port 443 on the server is already held by nginx or HAProxy, you can hide protocols behind it: the proxy accepts connections on 443 and hands them to protocols on 127.0.0.1:444, :445 and so on, by SNI.

In the connection settings, the Behind a proxy (nginx, HAProxy) block:

  • Where the node listens: “All addresses” (as usual), “Localhost only” (127.0.0.1) or “Own IP”.
  • Address for clients: the address clients get in the subscription. Empty: the node’s address.
  • Port for clients: usually 443, the proxy’s port. Empty: the connection’s port.
  • SNI for clients: for protocols with their own TLS name. With REALITY it stays the camouflage site’s domain, which is how the proxy tells connections apart.
stream {
map $ssl_preread_server_name $Arikan {
www.microsoft.com 127.0.0.1:444; # VLESS · REALITY, camouflage site
default 127.0.0.1:4430; # your site
}
server {
listen 443;
ssl_preread on;
proxy_pass $Arikan;
}
}

This is a sketch: use your own names and ports.

Automatic fixes are off for a connection behind a proxy and can’t be turned on:

  • the port isn’t moved, otherwise the proxy wouldn’t know the new one;
  • the camouflage site isn’t changed, because the proxy may route by its name.

Since 0.5.2.0 a CDN has presets of its own and a Behind a CDN block with the client’s real IP, see Behind a CDN. Below is the way without them, on WebSocket.

VLESS · TLS · WebSocket goes through a CDN (Cloudflare, Yandex Cloud CDN): clients connect to the CDN’s address, and the CDN passes the connection to the node. Where the server’s IP is blocked and the CDN’s network is not, this can save the day.

  1. Add a VLESS · TLS · WebSocket connection. Keep port 2053: Cloudflare passes only ports 443, 2053, 2083, 2087, 2096 and 8443 to a server.
  2. In the CDN, add a domain such as cdn.example.com with the node’s server address and turn proxying on (Cloudflare’s orange cloud). Cloudflare SSL mode: Full.
  3. In the connection’s Behind a proxy block: client address cdn.example.com, port 443, SNI cdn.example.com.

The node’s other protocols are not touched: they go to its address as before.

WebSocket alone is not enough to get through a whitelist: it is an older transport, and in Russia it gets blocked sooner than XHTTP. The scheme with two domains, XHTTP and the node’s own page is covered separately: Getting through whitelists over a CDN.