| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129 |
- {
- "log": {
- "loglevel": "debug"
- },
- "inbounds": [
- // 请求在该入站中被解密
- {
- "port": 4431,
- "listen": "127.0.0.1",
- "tag": "tls-decrypt",
- "protocol": "dokodemo-door",
- "settings": {
- "network": "tcp",
- // 从 TLS 的 SNI 中读出目标地址并应用至请求,用于后续路由
- "followRedirect": true
- },
- "streamSettings": {
- "security": "tls",
- "tlsSettings": {
- // 根据实际情况填写,这里适合绝大多数情况,如果你的网站仅支持 http/1.1, 就只保留 http/1.1
- // ps: 如果你选择了 http/1.1 那么你甚至可以用后续的路由模块屏蔽部分路径
- "alpn": [
- "h2",
- "http/1.1"
- ],
- "certificates": [
- {
- "usage": "issue",
- "buildChain": "true",
- // 下面的证书和私钥使用 xray tls cert -ca 命令生成,或者你的自签名证书也行
- // 这会生成一个 CA 证书,每个新的要被 MITM 网站请求都会单独用这个 CA 签发一张临时证书
- // 所以你只需要在系统信任这一张证书就可以了,或者你可以忍得了浏览器的红标无视风险继续访问也行
- "certificate": [],
- "key": []
- }
- ]
- }
- }
- },
- // 真正用到的入站
- {
- "port": 10801,
- "listen": "127.0.0.1",
- "tag": "socks-in",
- "protocol": "socks",
- "sniffing": {
- // 一般情况得开
- "enabled": true,
- "destOverride": [
- "http",
- "tls"
- ]
- }
- }
- ],
- "outbounds": [
- // 请求在该出站被强行重定向到 tls-decrypt 进行解密
- {
- "tag": "redirect-out",
- "protocol": "freedom",
- "settings": {
- "redirect": "127.0.0.1:4431"
- }
- },
- // 明文请求在这里被重新加密为正常 HTTPS 请求
- {
- "tag": "tls-repack",
- "protocol": "freedom",
- "settings": {
- // 你要连接到的服务器的最终IP以及端口,大多数情况下需要手动寻找这样允许域前置的IP
- "redirect": "104.20.19.168:443"
- },
- "streamSettings": {
- "security": "tls",
- "tlsSettings": {
- // fromMitm 会在客户端发送仅有 alpn http/1.1(大多数时候是wss) 的情况下使用同样的alpn, 需要 v25.2+
- // 旧版本没这个选项别直接把这玩意发出去了,从上面的alpn选项复制下来(当然更新版本最好)
- "alpn": [
- "fromMitm"
- ],
- // 你要发送的假 SNI, 根据你的网站接受的 SNI 而定
- // 当然你也可以留空或者我这样乱填个ip, 这样就不会有任何 SNI 扩展被发送,前提是你的网站接受无 SNI 请求
- "serverName": "11.45.1.4",
- // 你期望服务端返回证书里的包含的域名,这是新版本选项
- // 如果是旧版本只能考虑开允许不安全,然后可以考虑文档中其他校验证书的方法进行验证
- "verifyPeerCertInNames": "e-hentai.org"
- }
- }
- },
- // 无辜流量直接放行
- {
- "tag": "direct",
- "protocol": "freedom"
- }
- ],
- "routing": {
- "domainStrategy": "AsIs",
- "rules": [
- {
- "inboundTag": [
- "tls-decrypt"
- ],
- // tls-repark 中定义了一些参数(比如IP和SNI), 不同的网站可能需要不同的参数
- // 要支持更多的网站,可以新建更多的此类 freedom 出站,然后在这里把不同的明文请求按需求路由到不同的出站重新打包回 HTTPS
- // 这里的域名来源就是 tls-decrypt 入站的 followRedirect, 所以一个本地端口就可以接受任何网站的请求并在核心中这样区分开
- "domain": [
- "e-hentai.org"
- ],
- "outboundTag": "tls-repack"
- },
- {
- "inboundTag": [
- "socks-in"
- ],
- // 你要 mitm 的网址
- "domain": [
- "e-hentai.org"
- ],
- "outboundTag": "redirect-out"
- },
- {
- "inboundTag": [
- "socks-in"
- ],
- "outboundTag": "direct"
- }
- ]
- }
- }
|