Xray可以通过配置文件设置域名白名单,只允许特定的域名通过代理,其他的域名则会被拦截。具体配置方法如下:

  1. 打开Xray的配置文件'config.yml'。

  2. 在'inbound'配置中添加一个'domainStrategy'选项:

inbound:
  - port: 1080
    protocol: socks
    settings:
      auth: noauth
      domainStrategy: AsIs

其中的'domainStrategy'选项表示域名策略,'AsIs'表示保持原样,即不修改域名。

  1. 在'outbound'配置中添加一个'settings'选项,用于设置域名白名单:
outbound:
  - protocol: vmess
    settings:
      vnext:
        - address: example.com
          port: 443
          users:
            - id: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
              alterId: 64
              security: auto
    streamSettings:
      network: ws
      wsSettings:
        path: "/v2ray"
        headers:
          Host:
          - example.com
          - www.example.com

其中的'headers.Host'选项表示需要伪装的域名,可以设置多个域名。这里只允许'example.com'和'www.example.com'通过代理。

  1. 重新启动Xray。

这样,Xray就会自动拦截所有不在白名单中的域名,只允许特定的域名通过代理。

Xray 域名白名单设置教程:拦截非指定域名

原文地址: https://www.cveoy.top/t/topic/nT4E 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录