Xray behind nginx or Caddy: config generator with fallback and Reality
Pick the layout, enter the domain and take the files: nginx or Caddy in front of Xray, Reality and your own site on one port 443, or Xray in front with fallbacks. You get the web server's config, config.json for Xray, the client's vless:// link with a QR code, and the commands that check it all.
Runs in your browser, nothing is sent
Check your connection
Links and subscriptions
Network and router
DNS and addresses
nginx or Caddy holds 443 and the certificate, and sends one path to Xray on 127.0.0.1 or a socket.
Web server
nginx version
Transport
Xray listens on
What others see
Enter the domain, and the files will appear here.
Everything is worked out in your browser: keys and addresses are not sent anywhere.
Server ready? Connect to it in Veli: paste the link or the file into Add. The app can also set up a VPN on your VPS by itself.
Download VeliReference
How each transport is passed to Xray
What nginx and Caddy need to pass XHTTP, WebSocket, HTTPUpgrade and gRPC, and whether an Xray fallback can tell the transport apart by path.
- XHTTP
- /path/…
- location /path/ { grpc_pass … }
- path /path/*, h2c://
- Fallback by path: no
- WebSocket
- /path
- location = /path { proxy_pass … }
- path /path
- Fallback by path: yes
- HTTPUpgrade
- /path
- location = /path { proxy_pass … }
- path /path
- Fallback by path: yes
- gRPC
- /name/Tun
- location /name/Tun { grpc_pass … }
- path /name/Tun /name/TunMulti, h2c://
- Fallback by path: no
Which layout to choose
- Web server in front
- Several services on one server, a CDN in front, or a server where nginx or Caddy already runs. The certificate and renewal stay with the web server.
- Reality and a site
- Reality hides the server as a site. With your own site as the target nothing foreign is imitated, and the domain opens in a browser as usual.
- Xray in front (fallback)
- VLESS with Vision and your own certificate on 443, without a web server in the way of VPN traffic. Visitors get the site.
FAQ
Why put nginx or Caddy in front of Xray?
The domain then answers as an ordinary site with its own certificate, several services live on one port 443, and Xray listens only on 127.0.0.1 or a socket. A request with the right path goes to Xray, everything else goes to the site.
Which transport should I use behind nginx?
XHTTP: the Xray documentation advises moving to it from WebSocket, gRPC and HTTPUpgrade, whose ALPN or frames stand out. In nginx it is passed with grpc_pass, in Caddy with h2c. WebSocket is still the one that nearly every client knows.
What is a fallback in Xray?
Xray holds port 443 with your certificate itself. A connection that isn't VLESS is handed over to the web server on 127.0.0.1, already decrypted. Fallbacks work only over TCP with TLS, and by path they can tell apart only HTTP/1.1, that is WebSocket and HTTPUpgrade, not gRPC or XHTTP.
How do I run Reality and a site on one 443?
Either Xray listens on 443 and its target is your own nginx or Caddy on 127.0.0.1 (the server imitates its own site), or nginx listens on 443 and, by the name in the TLS handshake, sends the connection to Xray or to the site. The second way needs nginx with the stream module and a separate name for Reality.
Why do my nginx logs show 127.0.0.1 for every visitor?
The connection comes from Xray or from the stream block on the same server. Turn on PROXY protocol: the real address is passed in front of the connection, and the generator adds the lines that read it on both sides.
Will Veli open this link?
Yes: VLESS over XHTTP, WebSocket, gRPC, HTTPUpgrade and Reality. On a computer XHTTP is carried by Xray, which the app offers to install; on Android Xray is built in.