XTLS / Xray-core

Xray, Penetrates Everything. Also the best v2ray-core, with XTLS support. Fully compatible configuration.
https://t.me/projectXray
Mozilla Public License 2.0
23.18k stars 3.71k forks source link

Help with fallbacks #3353

Closed impossiblearchitect closed 2 months ago

impossiblearchitect commented 2 months ago

Hello all. Thanks for making it possible to breach the GFW.

I'm trying to set up a server using VLess-REALITY, with a fallback to a "decoy" website on port 444. That is, I'd like connections from a browser (or anything else not running XRay REALITY) to hit the website once they fail the first-packet screening. The "decoy" is in fact an existing server set up using Nginx and using Let's Encrypt/Certbot for HTTPS that I've been using for some time. If needed, I can provide the Nginx configuration as well, but I suspect that that's not the issue, as it's been minimally modified (I just switched it from listening on port 443 directly to 444) and I can still get the homepage with curl -k 127.0.0.1:444.

Is this in fact what the fallbacks option in XRay is for? That was my original impression when reading through the documentation, but several hours of debugging later I'm no longer convinced of my understanding.

Here's my configuration, with various parts censored with ◆s:

{
    "log": {
        "loglevel": "debug",
        "access": "/home/xray/xray_log/access.log",
        "error": "/home/xray/xray_log/error.log"
    },
    "routing": {
        "domainStrategy": "IPIfNonMatch",
        "rules": [
            {
                "type": "field",
                "domain": [
                    "geosite:category-ads-all"
                ],
                "outboundTag": "block"
            },
            {
                "type": "field",
                "domain": [
                    "geosite:cn"
                ],
                "outboundTag": "warp"
            },
            {
                "type": "field",
                "ip": [
                    "geoip:cn"
                ],
                "outboundTag": "warp"
            }
        ]
    },
    "inbounds": [
        {
            "port": 443,
            "protocol": "vless",
            "settings": {
                "clients": [
                    {
                        "id": "◆◆◆◆◆◆",
                        "flow": "xtls-rprx-vision",
                        "level": 0,
                        "email": "impossarchi@◆◆◆◆◆◆"
                    }
                ],
                "decryption": "none",
                "fallbacks": [{
                    "alpn": "h2",
                    "dest": 444
                }]
            },
            "streamSettings": {
                "network": "h2",
                "security": "reality",
                "realitySettings": {
                    "show": true,
                    "dest": "bancatransilvania.ro:443",
                    "xver": 1,
                    "serverNames": [
                        "bancatransilvania.ro",
                        "www.bancatransilvania.ro"
                    ],
                    "privateKey": "◆◆◆◆◆◆",
                    "minClientVer": "",
                    "maxClientVer": "",
                    "maxTimeDiff": 0,
                    "shortIds": [
                        "8a74"
                    ],
                   "fingerprint": "random",
                   "certificates": [
                        {
                            "ocspStapling": 3600,
                            "certificateFile": "/etc/letsencrypt/live/◆◆◆◆◆◆/fullchain.pem",
                            "keyFile": "/etc/letsencrypt/live/◆◆◆◆◆◆/privkey.pem"
                        }
                    ],
                    "minVersion": "1.2"
                }
            },
            "sniffing": {
                "enabled": true,
                "destOverride": [
                    "http",
                    "tls",
                    "quic"
                ]
            }
        }
    ],
    "outbounds": [
        {
            "protocol": "wireguard",
            "settings":{
                "secretKey": "◆◆◆◆◆◆",
                "address": ["10.0.8.255/32", "fd72:11c:d64d:ff::/128"],
                "peers": [
                    {
                        "publicKey": "◆◆◆◆◆◆",
                        "endpoint": "localhost:8107"
                    }
                ]
            },
            "tag": "outbound"
        },
        {
            "protocol": "blackhole",
            "tag": "block"
        },
        {
            "protocol": "wireguard",
            "settings": {
              "secretKey": "◆◆◆◆◆◆",
              "address": ["172.16.0.2/32", "◆◆◆◆◆◆"],
              "peers": [
                {
                  "publicKey": "bmXOC+F1FxEMF9dyiK2H5/1SUtzH0JuVo51h2wPfgyo=",
                  "endpoint": "engage.cloudflareclient.com:2408"
                }
              ]
            },
            "tag": "warp",
    "policy": {
        "levels": {
            "0": {
                "handshake": 3,
                "connIdle": 180
            }
        }
    }
}

Symptoms: All my connections cut out when TLS starts, by which I mean that when I use the Firefox or Edge dev console to look at my network packets I see that they cut out after the "establishing connection" stage. I think this is actually "progress" over a previous iteration of the configs, which just gave the sort of "invalid certificate" errors you'd expect from trying to use the certificates from one site at some other domain name -- an indication that REALITY is doing its job, to be sure, but leaving me very confused about what the fallbacks were (not?) doing; at least this way I can be sure that VLess is also doing its job and breaking the connection if it doesn't fit the protocol. But maybe it's actually a regression, and the way I had it the first time was better?

Regarding a few points where my configuration has been customized:

Thanks again for all your work; sorry for all the extra complexity; please advise!

Fangliding commented 2 months ago

First, fallback is unnecessary when using reality. When a reality server receives an unauthorized connect (such as from your browser), it will directly forward it to dest. Fallback inbound can only use "network": "tcp" realitySettings does not support "certificates". Don't add fields without your knowledge. "Wireguard outbound" is just a simple implement and not in line with wireguard's design intention. It's added is largely used to abuse the cloudflare warp service, and you cannot use the more advanced features of Wireguard VPN on Xray