利用xray反向代理搭建局域网

利用xray反向代理搭建局域网

portal

部署在有公网ip的服务器上,作为中转代理服务器

{
    "log": {
	    "access": "none",
        "loglevel": "warning"
    },
    "reverse": {
        "portals": [
            {
                "tag": "portal",
                "domain": "home.liangyufu.win"
            },
            {
                "tag": "portal_106",
                "domain": "106.xray.liangyufu.win"
            },
            {
                "tag": "portal_108",
                "domain": "108.xray.liangyufu.win"
            },
            {
                "tag": "portal_107",
                "domain": "107.xray.liangyufu.win"
            }
        ]
    },
    "inbounds": [
        {
            "tag": "browser-proxy-in",
            "listen": "0.0.0.0",
            "port": 8880,
            "protocol": "http"
        },
        {
            "tag": "browser-proxy-in2",
            "listen": "0.0.0.0",
            "port": 8881,
            "protocol": "Socks",
            "settings":{
              "auth": "noauth",
              "accounts": [
                {
                  "user": "my-username",
                  "pass": "my-password"
                }
              ],
              "udp": false,
              "ip": "127.0.0.1",
              "userLevel": 0
            }
        },
        {
            "tag": "tunnel",
            "listen": "0.0.0.0",
            "port": 1080,
            "protocol": "shadowsocks",
            "settings": {
                "method": "2022-blake3-aes-128-gcm",
                "password": "I4bq12n5LMrudltAyuwv6A==",
                "network": "tcp"
            }
        }
    ],
    "outbounds": [
        {
            "tag": "block",
            "protocol": "blackhole"
        },
        {
            "tag": "direct",
            "protocol": "freedom"
        }
    ],
    "routing": {
        "domainStrategy": "AsIs",
        "domainMatcher": "hybrid",
        "rules": [
            {
                "type": "field",
                "inboundTag": ["browser-proxy-in","browser-proxy-in2","tunnel"],
                "ip": ["10.6.0.0/16"],
                "outboundTag": "portal_106"
            },
            {
                "type": "field",
                "inboundTag": ["tunnel"],
                "domain": "106.xray.liangyufu.win",
                "outboundTag": "portal_106"
            },
            {
                "type": "field",
                "inboundTag": ["browser-proxy-in","browser-proxy-in2","tunnel"],
                "ip": ["10.8.0.0/16"],
                "outboundTag": "portal_108"
            },
            {
                "type": "field",
                "inboundTag": ["tunnel"],
                "domain": "108.xray.liangyufu.win",
                "outboundTag": "portal_108"
            },
            {
                "type": "field",
                "inboundTag": ["browser-proxy-in","browser-proxy-in2","tunnel"],
                "ip": ["10.7.0.0/16"],
                "outboundTag": "portal_107"
            },
            {
                "type": "field",
                "inboundTag": ["tunnel"],
                "domain": "107.xray.liangyufu.win",
                "outboundTag": "portal_107"
            },
            {
                "type": "field",
                "inboundTag": ["browser-proxy-in","browser-proxy-in2","tunnel"],
                "balancerTag": "lb_outside"
            }
        ],
        "balancers": [
            {
              "tag": "lb_outside",
              "selector": ["portal_107","portal_108"],
              "fallbackTag": "direct",
              "strategy": {
                    "type": "leastPing",
                    "settings": {}
              }
            }
        ]
    },
    "observatory": {
        "subjectSelector":["portal_106","portal_107","portal_108"],
        "probeUrl": "http://www.gstatic.com/generate_204",
        "probeInterval": "10s",
        "enableConcurrency": false
    }
}

bridge

部署在局域网内部服务器上,作为访问出口

{
    "log": {
	    "access": "none",
        "loglevel": "warning"
    },
    "reverse": {
        "bridges": [
            {
                "tag": "bridge",
                "domain": "106.xray.liangyufu.win"
            }
        ]
    },
    "outbounds": [
        {
            "tag": "block",
            "protocol": "blackhole"
        },
        {
            "tag": "direct",
            "protocol": "freedom"
        },
        {
            "tag": "tunnel",
            "protocol": "shadowsocks",
            "settings": {
                "servers": [
                    {
                      "address": "home.liangyufu.win",
                      "port": 17888,
                      "method": "2022-blake3-aes-128-gcm",
                      "password": "I4bq12n5LMrudltAyuwv6A==",
                      "uot": true
                    }
                ]
            }
        }
    ],
    "routing": {
        "domainStrategy": "IPIfNonMatch",
        "domainMatcher": "hybrid",
        "rules": [
            {
                "type": "field",
                "inboundTag": ["dns-module"],
                "outboundTag": "direct"
            },
            {
                "type": "field",
                "inboundTag": ["bridge"],
                "domain": ["full:106.xray.liangyufu.win"],
                "outboundTag": "tunnel"
            },
            {
                "type": "field",
                "inboundTag": ["bridge"],
                "outboundTag": "direct"
            }
        ]
    },
	"observatory": {}
}