Add Clash subscription with User-Agent routing

- clash.yaml template (proxy-providers -> x-ui base64 sub URL) in assets/clash/
- install_clash_sub() downloads and substitutes domain/sub_path at install time
- nginx: map $http_user_agent $is_clash_client detects Clash/Mihomo/Stash/Surfboard
- sub_path locations rewrite to internal /__clash_sub on UA match
- /__clash_sub serves /var/www/subpage/clash.yaml as text/yaml
- Regular clients still proxy to x-ui sub port unchanged
- Uninstall cleans /var/www/subpage/

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
Ivan Razin
2026-06-24 13:29:16 +03:00
co-authored by Claude Sonnet 4.6
parent c548d9934a
commit 138e41574c
2 changed files with 129 additions and 2 deletions
+92
View File
@@ -0,0 +1,92 @@
mixed-port: 7890
allow-lan: false
log-level: info
ipv6: false
mode: rule
dns:
enable: true
use-hosts: true
ipv6: false
enhanced-mode: redir-host
listen: 127.0.0.1:6868
default-nameserver:
- 1.1.1.1
- 8.8.8.8
- 1.0.0.1
nameserver:
- https://1.1.1.1/dns-query#PROXY
- https://8.8.8.8/dns-query#PROXY
- https://1.0.0.1/dns-query#PROXY
- 8.8.8.8
- 1.1.1.1
profile:
store-selected: true
proxy-groups:
- name: PROXY
proxies:
- auto
use:
- sub
type: select
- name: auto
use:
- sub
type: url-test
url: http://cp.cloudflare.com
interval: 300
tolerance: 150
lazy: true
proxy-providers:
sub:
type: http
url: https://${DOMAIN}/${SUB_PATH}/
path: ./proxy_providers/base64.yml
interval: 3600
health-check:
enable: true
url: https://www.gstatic.com/generate_204
interval: 300
timeout: 5000
lazy: true
expected-status: 204
rule-providers:
ru-bundle:
type: http
behavior: domain
format: mrs
url: https://github.com/legiz-ru/mihomo-rule-sets/raw/main/ru-bundle/rule.mrs
path: ./ru-bundle/rule.mrs
interval: 86400
rules:
- PROCESS-NAME,Discord.exe,PROXY
- PROCESS-NAME,com.supercell.clashofclans,PROXY
- PROCESS-NAME,com.supercell.brawlstars,PROXY
- RULE-SET,ru-bundle,PROXY
- MATCH,DIRECT
sniffer:
enable: true
force-dns-mapping: true
parse-pure-ip: true
sniff:
HTTP:
ports: [80, 8080-8880]
override-destination: true
TLS:
ports: [443, 8443]
tun:
enable: true
stack: system
dns-hijack:
- any:53
auto-redir: true
auto-route: true
auto-detect-interface: true