xray-examples Configuration Guide

repository·main·Indexed 21 days ago

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

Configuration examples for Xray-core focusing on transport protocols including VLESS with Vision, REALITY, gRPC, and WebSocket. Includes setup guides for clients such as v2rayN, v2rayNG, Shadowrocket, PassWall, ShadowSocksR Plus+, and HomeProxy, as well as technical details on Mux (Multiplexing) and MPTCP (Multi-Path TCP) requirements.

Tokens
11.7K
Snippets
29
Records
58
Agent score
76%

What's inside xray-examples

  1. Performance optimization for gRPC/H2

    main
    When using gRPC or HTTP/2 (H2) transports, it is recommended to use a VPS with optimized return routing, such as CN2-GIA, AS9929/AS10099, CMI/CMIN2, or AS4837. Lower latency between you and the VPS is critical for performance. For further optimization, consider following NaïveProxy's Performance Tuning guide and utilizing the health check parameters in your Xray configuration.
  2. Use XUDP and Global ID for improved P2P (v1.8.1+)

    main
    Starting from Xray-core v1.8.1, the implementation of Global ID & UoT (Mux.Cool) migration provides significant benefits for P2P connections. Even if the TCP connection is interrupted (e.g., switching from WiFi to mobile data), the server will continue to use the same exit port (Port A) upon reconnection, rather than switching to a new port (Port B). This effectively enables a 'FullCone' experience for VLESS users.
  3. Performance considerations for gRPC/H2

    main
    When using gRPC or H2 transport protocols, it is recommended to use a VPS with optimized return routing (e.g., CN2-GIA, AS9929/AS10099, CMI/CMIN2, AS4837). Lower latency between the client and the VPS is critical for performance. For further optimization, consider using the health check parameters in the Xray configuration.
  4. Optimize REALITY performance via target domain selection

    main

    The choice of the target domain/website used in REALITY significantly impacts latency, speed, and stability. Consider the following factors:

    1. Proximity/Stability: The target website should be close to the server and stable (avoid sites that might rate-limit frequent handshake requests).
    2. ISP Priority: Some operators grant higher traffic priority to specific domains.
    3. GFW Lists: Be aware of GFW blacklists (e.g., Google) and whitelists (e.g., Microsoft).
  5. Understand WireGuard domainStrategy behaviors

    main

    The domainStrategy setting in the WireGuard outbound determines how Xray resolves domain names before sending the connection through the WireGuard tunnel.

    domainStrategychat.openai.comNotes
    ForceIPv6v4IPv6Recommended for using Cloudflare's IPv4 via WARP
    ForceIPv6IPv6May cause issues if the site doesn't support IPv6
    ForceIPv4v6IPv4Might trigger browser warnings about IPv6 availability
    ForceIPv4IPv4Forces IPv4
    ForceIP (default)IPv6Uses Xray's internal DNS to get IP, then sends via WireGuard
  6. Optimize gRPC/H2 Performance

    main

    When using gRPC or H2 transports, it is recommended to use a VPS with optimized return routing (e.g., CN2-GIA, AS9929/AS10099, CMI/CMIN2, AS4837). Performance is highly dependent on low latency between the client and the VPS.

    To improve stability and performance, consider:

    1. Following NaïveProxy Performance Tuning guidelines.
    2. Using the healthCheck parameter in your Xray configuration to monitor connection quality.
  7. Avoid using WSS (WebSocket over TLS) for proxying

    main

    WSS is considered deprecated for high-security needs due to several identifiable features:

    • ALPN Fingerprint: WSS often sends an ALPN of http/1.1, making it easily identifiable.
    • Handshake Timing: The extra WebSocket handshake creates unique timing signatures.
    • TLS in TLS: WSS is susceptible to TLS in TLS detection.

    Recommendations:

    • Do not use WSS.
    • If you must use WSS, use early data by appending ?ed=2048 to mitigate handshake issues.
    • Use REALITY or gRPC over CDN instead.
  8. Mitigate active probing by customizing policy timeouts

    main
    To prevent GFW active probing from identifying Xray based on default handshake and connection idle timeouts, customize the policy settings. Avoid using the default values (e.g., 60s handshake, 300s connection idle) as they create a recognizable signature.
  9. Get WARP credentials via api.zeroteam.top

    main

    You can fetch WARP credentials in sing-box format using the following command. You will need to extract the IPv6 address, private_key, and reserved values for your Xray configuration.

    • IPv6 Address: Replace 2606:4700:: in your config with this address (append /128).
    • private_key: Paste this value into the secretKey field.
    • reserved: Paste this array into the reserved field.
    curl -sL "https://api.zeroteam.top/warp?format=sing-box" | grep -Eo --color=never '"2606:4700:[0-9a-f:]+/128"|"private_key":"[0-9a-zA-Z\/\+]+="|"reserved":\[[0-9]+(,[0-9]+){2}\]'
  10. Verify REALITY port forwarding with a browser

    main

    Since REALITY acts as a port forwarder for non-REALITY clients, accessing the IP directly via a browser will likely result in certificate errors or unexpected responses.

    To correctly verify the REALITY port forwarding using a browser:

    1. Modify your system's hosts file.
    2. Map the target domain (the one used in REALITY's serverName) to your server's IP.
    3. Access the target domain via the browser. You should see a normal response, and the browser's Network tab (F12) will show the connection is actually established with your server's IP.
  11. Best practices for configuring XTLS Vision to avoid detection

    main

    To minimize the risk of port or IP blocking when using XTLS Vision, follow these configuration requirements:

    1. Server-side IP Management: Use a clean IP and ensure the server blocks all domestic (China) IP traffic to prevent your local IP from being flagged via timing correlation.
    2. Port Configuration: Use reasonable ports and strictly forbid domestic traffic.
    3. Protocol Isolation: Configure the server to use only XTLS Vision. Do not allow compatibility with standard TLS proxies.
    4. Fallback Behavior: Configure the server to fall back to a standard webpage, or do not implement fallback/splitting to other proxy protocols.
    5. Client-side Fingerprinting: Ensure the client has uTLS (fingerprint) enabled.

    Note: Even with correct configuration, 100% protection is not guaranteed. If a port is blocked, try changing the port, the IP, or the service provider.