設定 · Clash ドキュメント

Inbound

Clash の HTTP(S)、SOCKS5、mixed-port、Redirect、TProxy、TUN インバウンドを整理し、待受ポート、allow-lan、透過プロキシ関連フィールドと適用範囲を説明します。

  • mixed-port
  • SOCKS5
  • Redirect
  • TProxy
  • allow-lan
設定

Clash は、次のような複数のインバウンドプロトコルに対応しています:

  • SOCKS5
  • HTTP(S)
  • Redirect TCP
  • TProxy TCP
  • TProxy UDP
  • Linux TUN デバイス(Premium バージョンのみ)

どのインバウンドプロトコルからの接続も、同じ内部ルール照合エンジンで処理されます。つまり、Clash は現時点では、インバウンドプロトコルごとに異なるルールセットを設定することには対応していません。

設定

yaml
# HTTP(S) 代理服务端口
# port: 7890

# SOCKS5 代理服务端口
socks-port: 7891

# HTTP(S) 和 SOCKS4(A)/SOCKS5 代理服务共用一个端口
mixed-port: 7890

# Linux 和 macOS 的透明代理服务端口 (TCP 和 TProxy UDP 重定向)
# redir-port: 7892

# Linux 的透明代理服务端口 (TProxy TCP 和 TProxy UDP)
# tproxy-port: 7893

# 设置为 true 以允许来自其他 LAN IP 地址的连接
# allow-lan: false

Mixed 混合ポート

混合ポートは、HTTP(S) と SOCKS5 の両方に対応する特別なポートです。HTTP または SOCKS プロキシに対応する任意のプログラムから、このポートへ接続できます。例:

shell
$ curl -x socks5h://127.0.0.1:7890 -v http://connect.rom.miui.com/generate_204
*   Trying 127.0.0.1:7890...
* SOCKS5 connect to connect.rom.miui.com:80 (remotely resolved)
* SOCKS5 request granted.
* Connected to (nil) (127.0.0.1) port 7890 (#0)
> GET /generate_204 HTTP/1.1
> Host: connect.rom.miui.com
> User-Agent: curl/7.81.0
> Accept: */*
>
* Mark bundle as not supporting multiuse
< HTTP/1.1 204 No Content
< Date: Thu, 11 May 2023 06:18:22 GMT
< Connection: keep-alive
< Content-Type: text/plain
<
* Connection #0 to host (nil) left intact

Redirect と TProxy

Redirect と TProxy は、透過プロキシを実現する二つの異なる方式で、どちらも Clash が対応しています。

ただし、この二つを手動で設定する必要はありません。オペレーティングシステムのルーティングテーブル、ルール、nftables を自動管理できるため、透過プロキシの構成には Clash Premium バージョン の使用を推奨します。