xray-examples

repository·main·Indexed 26 days ago

https://github.com/xtls/xray-examples

A collection of configuration examples and use cases for the Xray-core proxy engine. It includes practical references for implementing features such as All-in-One configurations with Nginx decoys, Hysteria2, MITM domain fronting, reverse proxy architectures (Client, Portal, Bridge), and serverless setups for censorship bypass. The repository provides guidance on protocol-transport combinations (Trojan, Vless, VMESS, ShadowSocks), routing logic, and the use of a config generation script.

Tokens
15K
Snippets
20
Records
73
Agent score
86%

What's inside xray-examples

  1. Overview of MITM Domain Fronting Template

    main

    This project provides a client-side template for performing MITM (Man-in-the-Middle) decryption of TLS requests and re-issuing them with a fake SNI (Server Name Indication). This mechanism achieves forced domain fronting.

    Key Use Cases:

    • Achieving domain fronting.
    • TLS offloading for subsequent processing.
    • Encrypting plaintext data into a TLS tunnel.

    Prerequisites:

    • A deep understanding of TLS and HTTPS protocols (specifically SNI and ALPN mechanisms).
    • The target website must accept domain fronting or requests without SNI.
    • The target IP must not be blocked by a firewall.

    Note: This is a demonstration template. The example uses e-hentai because its frontend structure is simple, but other websites may require additional handling for various resource domains.

  2. Overview of Shadowsocks AEAD with Xray-core

    main

    Using Xray-core, you can establish a Shadowsocks AEAD encrypted tunnel that supports Socks, HTTP proxies, and UDP FullCone.

    Key features include:

    • Single Port Multi-User Support: The server can handle multiple users with different credentials on a single port.
    • Full UDP Support: Xray-core provides robust UDP support; Socks inbounds can accept UDP requests from any network interface.
    • High Performance: Designed to be high-performance, cross-platform, and easy to compile.
  3. Overview of VLESS-TLS-SplitHTTP-H3

    main

    VLESS-TLS-SplitHTTP-H3 is a configuration pattern that utilizes HTTP/3 (H3) for transport. It supports two primary connection modes:

    1. Direct Connection: The Xray client communicates directly with the Xray server via HTTP/3. Xray client <--- HTTP3 ---> Xray server

    2. CDN Integration: The Xray client communicates with a CDN via HTTP/3, while the CDN communicates with the Xray server via HTTP/2 or HTTP/1.1. Xray client <--- HTTP3 ---> CDN <--- HTTP2 or HTTP/1.1 ---> Xray server

  4. Overview of VLESS-XHTTP-Reality-steal_others configuration

    main

    This configuration example demonstrates a minimal setup combining VLESS, XHTTP, and REALITY technologies. It is designed for use with modern versions of Xray-core.

    Requirements

    • Xray-core version: Must be v25.3.6 or newer. This configuration will not work on older versions.
    • Routing Recommendation: For users in mainland China, it is recommended to use routing rules that block traffic to domestic websites (e.g., using server-block-cn.jsonc) to prevent the server from being flagged as a proxy when connecting to domestic sites.

    Configuration Features

    • Minimalism: Fields that require user-specific input are left empty to ensure Xray-core throws an error if a user attempts to run it without proper configuration.
    • Domain Sniffing: Enabled for improved practicality.
    • Fingerprint: The fingerprint field for REALITY is omitted because Xray-core (v24.12.18+) defaults to chrome automatically.
  5. Overview of Hysteria2 Examples

    main

    This repository provides configuration examples for the Hysteria2 protocol, specifically focusing on the server-side inbound and the client-side outbound settings.

    Note on Congestion Control: When using the brutal congestion control algorithm, ensure your bandwidth characteristics are compatible. If unsure, it is recommended to use bbr instead.

  6. Overview of VLESS over TCP with TLS + fallback & split to WebSocket

    main

    This advanced configuration implements VLESS over TCP with TLS on port 443. It utilizes VLESS fallback and distribution features to allow for the perfect coexistence of VLESS and any WebSocket Secure (WSS) protocol on the same port.

    Key features:

    • Coexistence: Allows connecting via VLESS over TCP with TLS and any WebSocket with TLS simultaneously.
    • CDN Support: The WebSocket portion can be routed through a CDN.
    • Performance: This configuration's performance for fallback shunting to WebSocket is measured to be stronger than using an Nginx reverse proxy for WebSocket generation.
    • Migration: Traditional VMess + WSS solutions can be migrated to this setup without losing compatibility.

    Note: This configuration is provided for reference. You can replace VLESS on WS with other protocols (like VMess) and define additional PATHs and protocol coexistence settings.

  7. Overview of the Xray Reverse Proxy Architecture

    main

    The Xray Reverse Proxy setup allows a client to connect to an internal device through a public-facing portal. The architecture follows this flow:

    Xray Client <--- VMESS/SS ---> Xray Portal (Public IP) <--- VMESS/SS ---> Xray Bridge

    In this setup:

    • Xray Client: The end-user device.
    • Xray Portal: A device with a public IP that acts as the intermediary.
    • Xray Bridge: The internal device being accessed.

    Commonly used transport protocols for the connections include VMESS-TCP and Shadowsocks-2022.

  8. Overview of Xray HTTP/2 and HTTP/3 Proxying via Caddy

    main

    Xray's HTTP/2 and HTTP/3 transport modes strictly follow HTTP standards, allowing them to be proxied through standard HTTP servers like Caddy.

    To prevent middlebox detection of Xray-core, use Caddy's reverse_proxy module with path-based routing. Configure a complex path for the proxy to disguise the traffic, while the main path serves a legitimate website. This ensures that an observer cannot easily distinguish Xray traffic from standard web traffic.

  9. Prerequisites for VLESS over TCP with TLS + Fallback

    main

    To use the minimal VLESS over TCP with TLS and fallback configuration, you must satisfy the following requirements:

    1. Domain Name: A domain name pointing to your server's IP address.
    2. SSL Certificate: A valid SSL certificate for your domain (e.g., obtained via Let's Encrypt).
    3. Web Server: A web server such as Nginx or Caddy installed on the server to handle fallback traffic.
  10. VLESS over TCP with TLS + Fallback & WebSocket (Advanced Configuration)

    main

    This configuration is an advanced superset of the minimal VLESS-TCP-TLS setup. It leverages VLESS's fallback and traffic splitting capabilities to allow VLESS over TCP with TLS and any WebSocket Secure (WSS) protocol to coexist on port 443.

    Key Features:

    • Allows simultaneous connections via VLESS over TCP with TLS and any WebSocket with TLS.
    • WebSocket connections can be routed through a CDN.
    • Provides better performance than using Nginx as a reverse proxy for WebSocket traffic.
    • Compatible with traditional VMess + WSS migration paths.

    ⚠️ SECURITY WARNING: This configuration was previously recommended, but it has been identified as having security flaws. It is now considered deprecated. Use with caution and consider migrating to more modern configurations like XTLS.

  11. Architecture Overview of VLESS-H2C-Caddy

    main

    This setup implements a VLESS protocol over HTTP/2 (H2) using Caddy as a proxy. The data flow follows this path:

    Xray client <--- H2 ---> Caddy2 <--- H2C ---> Xray server

    This architecture allows the client to communicate with Caddy via standard HTTP/2, while Caddy communicates with the Xray server using H2C (HTTP/2 over Cleartext).

    Xray client <--- H2 ---> Caddy2 <--- H2C ---> Xray server