config.jsonc 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129
  1. {
  2. "log": {
  3. "loglevel": "debug"
  4. },
  5. "inbounds": [
  6. // 请求在该入站中被解密
  7. {
  8. "port": 4431,
  9. "listen": "127.0.0.1",
  10. "tag": "tls-decrypt",
  11. "protocol": "dokodemo-door",
  12. "settings": {
  13. "network": "tcp",
  14. // 从 TLS 的 SNI 中读出目标地址并应用至请求,用于后续路由
  15. "followRedirect": true
  16. },
  17. "streamSettings": {
  18. "security": "tls",
  19. "tlsSettings": {
  20. // 根据实际情况填写,这里适合绝大多数情况,如果你的网站仅支持 http/1.1, 就只保留 http/1.1
  21. // ps: 如果你选择了 http/1.1 那么你甚至可以用后续的路由模块屏蔽部分路径
  22. "alpn": [
  23. "h2",
  24. "http/1.1"
  25. ],
  26. "certificates": [
  27. {
  28. "usage": "issue",
  29. "buildChain": "true",
  30. // 下面的证书和私钥使用 xray tls cert -ca 命令生成,或者你的自签名证书也行
  31. // 这会生成一个 CA 证书,每个新的要被 MITM 网站请求都会单独用这个 CA 签发一张临时证书
  32. // 所以你只需要在系统信任这一张证书就可以了,或者你可以忍得了浏览器的红标无视风险继续访问也行
  33. "certificate": [],
  34. "key": []
  35. }
  36. ]
  37. }
  38. }
  39. },
  40. // 真正用到的入站
  41. {
  42. "port": 10801,
  43. "listen": "127.0.0.1",
  44. "tag": "socks-in",
  45. "protocol": "socks",
  46. "sniffing": {
  47. // 一般情况得开
  48. "enabled": true,
  49. "destOverride": [
  50. "http",
  51. "tls"
  52. ]
  53. }
  54. }
  55. ],
  56. "outbounds": [
  57. // 请求在该出站被强行重定向到 tls-decrypt 进行解密
  58. {
  59. "tag": "redirect-out",
  60. "protocol": "freedom",
  61. "settings": {
  62. "redirect": "127.0.0.1:4431"
  63. }
  64. },
  65. // 明文请求在这里被重新加密为正常 HTTPS 请求
  66. {
  67. "tag": "tls-repack",
  68. "protocol": "freedom",
  69. "settings": {
  70. // 你要连接到的服务器的最终IP以及端口,大多数情况下需要手动寻找这样允许域前置的IP
  71. "redirect": "104.20.19.168:443"
  72. },
  73. "streamSettings": {
  74. "security": "tls",
  75. "tlsSettings": {
  76. // fromMitm 会在客户端发送仅有 alpn http/1.1(大多数时候是wss) 的情况下使用同样的alpn, 需要 v25.2+
  77. // 旧版本没这个选项别直接把这玩意发出去了,从上面的alpn选项复制下来(当然更新版本最好)
  78. "alpn": [
  79. "fromMitm"
  80. ],
  81. // 你要发送的假 SNI, 根据你的网站接受的 SNI 而定
  82. // 当然你也可以留空或者我这样乱填个ip, 这样就不会有任何 SNI 扩展被发送,前提是你的网站接受无 SNI 请求
  83. "serverName": "11.45.1.4",
  84. // 你期望服务端返回证书里的包含的域名,这是新版本选项
  85. // 如果是旧版本只能考虑开允许不安全,然后可以考虑文档中其他校验证书的方法进行验证
  86. "verifyPeerCertInNames": "e-hentai.org"
  87. }
  88. }
  89. },
  90. // 无辜流量直接放行
  91. {
  92. "tag": "direct",
  93. "protocol": "freedom"
  94. }
  95. ],
  96. "routing": {
  97. "domainStrategy": "AsIs",
  98. "rules": [
  99. {
  100. "inboundTag": [
  101. "tls-decrypt"
  102. ],
  103. // tls-repark 中定义了一些参数(比如IP和SNI), 不同的网站可能需要不同的参数
  104. // 要支持更多的网站,可以新建更多的此类 freedom 出站,然后在这里把不同的明文请求按需求路由到不同的出站重新打包回 HTTPS
  105. // 这里的域名来源就是 tls-decrypt 入站的 followRedirect, 所以一个本地端口就可以接受任何网站的请求并在核心中这样区分开
  106. "domain": [
  107. "e-hentai.org"
  108. ],
  109. "outboundTag": "tls-repack"
  110. },
  111. {
  112. "inboundTag": [
  113. "socks-in"
  114. ],
  115. // 你要 mitm 的网址
  116. "domain": [
  117. "e-hentai.org"
  118. ],
  119. "outboundTag": "redirect-out"
  120. },
  121. {
  122. "inboundTag": [
  123. "socks-in"
  124. ],
  125. "outboundTag": "direct"
  126. }
  127. ]
  128. }
  129. }