diff --git a/.github/workflows/caddy.yml b/.github/workflows/caddy.yml new file mode 100644 index 00000000000..52e5d52a27e --- /dev/null +++ b/.github/workflows/caddy.yml @@ -0,0 +1,158 @@ +name: Build caddy + +on: + workflow_dispatch: + + release: + types: + - 'prereleased' + - 'published' + - 'released' + +jobs: + build: + runs-on: ubuntu-latest + strategy: + fail-fast: false + matrix: + config: + - { + name: "windows-386", + GOARCH: 386, + GOOS: windows, + release: true + } + - { + name: "windows-amd64", + GOARCH: amd64, + GOOS: windows, + release: true + } + - { + name: "linux-amd64", + GOARCH: amd64, + GOOS: linux, + release: true + } + - { + name: "linux-arm64", + GOARCH: arm64, + GOOS: linux, + release: true + } + - { + name: "linux-armv5", + GOARCH: arm, + GOARM: 5, + GOOS: linux, + release: true + } + - { + name: "linux-s390x", + GOARCH: s390x, + GOOS: linux, + release: true + } + - { + name: "freebsd-amd64", + GOARCH: amd64, + GOOS: freebsd, + release: true + } + - { + name: "freebsd-arm64", + GOARCH: arm64, + GOOS: linux, + release: true + } + - { + name: "darwin-amd64", + GOARCH: amd64, + GOOS: darwin, + release: true + } + - { + name: "darwin-arm64", + GOARCH: arm64, + GOOS: darwin, + release: true + } + + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install go + uses: actions/setup-go@v3 + with: + go-version: '1.20' + check-latest: true + + - name: Install xcaddy + run: go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest + + - name: Build caddy + run: | + mkdir release-tmp + export GOARCH=${{ matrix.config.GOARCH }} + export GOOS=${{ matrix.config.GOOS }} + ~/go/bin/xcaddy build \ + --with github.com/mholt/caddy-l4 \ + --with github.com/caddy-dns/cloudflare \ + --with clevergo.tech/caddy-dnspodcn \ + --with github.com/caddy-dns/duckdns \ + --with github.com/mholt/caddy-dynamicdns \ + --with github.com/mholt/caddy-events-exec \ + --with github.com/WeidiDeng/caddy-cloudflare-ip \ + --with github.com/caddyserver/forwardproxy@caddy2=github.com/sagernet/forwardproxy@latest \ + --with github.com/imgk/caddy-trojan \ + --with github.com/mholt/caddy-webdav \ + --output ./release-tmp/caddy + + - name: Rename for Windows + if: matrix.config.GOOS == 'windows' + run: | + mv ./release-tmp/caddy ./release-tmp/caddy.exe + + - name: Calculate Hash + run: | + cd ./release-tmp || exit 1 + sha256sum * > sha256 + + - name: Generate zip for Windows + if: matrix.config.GOOS == 'windows' + run: | + mkdir release-ready + cd ./release-tmp + zip -r ../release-ready/caddy-${{ matrix.config.name }}.zip * + + - name: Generate tar for other platform + if: matrix.config.GOOS != 'windows' + run: | + mkdir release-ready + cd ./release-tmp + tar -zcvf ../release-ready/caddy-${{ matrix.config.name }}.tar.gz * + + - name: Upload a Build Artifact + uses: actions/upload-artifact@v3 + with: + name: caddy-${{ github.sha }}-${{ matrix.config.name }} + path: ./release-ready/* + + - name: Upload to GitHub Release for Windows + uses: svenstaro/upload-release-action@v2 + if: github.event_name == 'release' && matrix.config.release && matrix.config.GOOS == 'windows' + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./release-ready/caddy-${{ matrix.config.name }}.zip + tag: ${{ github.ref }} + overwrite: true + + - name: Upload to GitHub Release for other platform + uses: svenstaro/upload-release-action@v2 + if: github.event_name == 'release' && matrix.config.release && matrix.config.GOOS != 'windows' + with: + repo_token: ${{ secrets.GITHUB_TOKEN }} + file: ./release-ready/caddy-${{ matrix.config.name }}.tar.gz + tag: ${{ github.ref }} + overwrite: true diff --git a/Caddy(N+T)/README.md b/Caddy(N+T)/README.md new file mode 100644 index 00000000000..1df8059237d --- /dev/null +++ b/Caddy(N+T)/README.md @@ -0,0 +1,13 @@ +介绍: + +本示例使用 Caddy 源码加改进版 forwardproxy 插件、caddy-trojan 插件编译而成 Caddy 文件,实现了 NaiveProxy 与 Trojan-Go 服务端加伪装网站应用。 + +注意: + +1、使用本人 Releases 中编译好的 Caddy 文件,可同时支持 NaiveProxy、Trojan-Go 等应用。 + +2、本示例 NaiveProxy 除了支持 HTTP/2 代理应用,还同时支持 HTTP/3 代理应用,即 QUIC 协议传输。若 NaiveProxy 使用 HTTP/3 代理应用,建议增加 [UDP 接收缓冲区大小](https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size)。 + +3、本示例 Trojan-Go 仅兼容原版服务端的核心应用:支持 Trojan 应用与 Trojan-Go 的 WebSocket 应用共存,支持 CDN 流量中转(基于 WebSocket over TLS)。客户端推荐选择 Xray 客户端,支持使用指纹伪造;WebSocket 应用不能启用 WebSocket 0-RTT 与多路复用,不兼容。 + +4、本示例 Caddy 支持自动 HTTPS,即自动申请与更新 TLS 证书,自动 HTTP 重定向到 HTTPS。 diff --git a/Caddy(N+T)/caddy.json b/Caddy(N+T)/caddy.json new file mode 100644 index 00000000000..6495946a4ef --- /dev/null +++ b/Caddy(N+T)/caddy.json @@ -0,0 +1,114 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "apps": { + "http": { + "servers": { + "https": { + "listen": [":443"], + "listener_wrappers": [{ + "wrapper": "trojan" //caddy-trojan插件应用必须配置 + }], + "routes": [{ + "handle": [{ + "handler": "forward_proxy", + "auth_user_deprecated": "user", //NaiveProxy用户,修改为自己的。 + "auth_pass_deprecated": "pass", //NaiveProxy密码,修改为自己的。 + "hide_ip": true, + "hide_via": true, + "probe_resistance": {} + }] + }, + { + "handle": [{ + "handler": "trojan", + "connect_method": true, + "websocket": true + }] + }, //此部分配置为caddy-trojan插件的WebSocket应用,若删除就仅支持Trojan应用。 + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["z2.xx.yy","h3.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2","h3"] //默认配置 + } + } + }, + "trojan": { + "proxy": { + "proxy": "no_proxy" + }, + "upstream": { + "upstream": "memory" + }, + "users": ["diy443"] //修改为自己的密码。密码可多组("password"),用逗号隔开。 + }, + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy","h3.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//3、本配置使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 +//4、本配置使用不同域名来实现介绍中各应用,其办法如下: +//1)、NaiveProxy使用HTTPS协议时用z1.xx.yy域名,使用QUIC协议时用h3.xx.yy域名。 +//2)、Trojan-Go使用Trojan应用时用z1.xx.yy域名,使用WebSocket应用时用z2.xx.yy域名。 diff --git a/Caddy(Other Configuration)/DDNS_Caddyfile b/Caddy(Other Configuration)/DDNS_Caddyfile new file mode 100644 index 00000000000..bef5daa28f6 --- /dev/null +++ b/Caddy(Other Configuration)/DDNS_Caddyfile @@ -0,0 +1,26 @@ +#DDNS客户端配置 +#原配置: +{ +#........<省略>........ + log { + output file /var/log/caddy/error.log + level ERROR + } #版本不小于v2.4.0才支持日志全局配置 +#........<省略>........ +} + +#以上配置修改为如下: +{ +#........<省略>........ + log { + output file /var/log/caddy/error.log + level ERROR + } #版本不小于v2.4.0才支持日志全局配置 + dynamic_dns { #加了caddy-dynamicdns插件编译的才支持DDNS应用 + provider duckdns b8a33cc1-3333-2222-a1e6-b049bf07988f #可修改为其它caddy-dns插件(加了对应插件编译的才支持)及对应caddy-dns插件的token + domains { + xdddns.duckdns.org #修改为关联的域名 + } + } +#........<省略>........ +} diff --git a/Caddy(Other Configuration)/DDNS_caddy.json b/Caddy(Other Configuration)/DDNS_caddy.json new file mode 100644 index 00000000000..85c195b5e77 --- /dev/null +++ b/Caddy(Other Configuration)/DDNS_caddy.json @@ -0,0 +1,25 @@ +//DDNS客户端配置 +//原配置: +{ +//........<省略>........ + "apps": { +//........<省略>........ + } +} + +//以上配置修改为如下: +{ +//........<省略>........ + "apps": { + "dynamic_dns": { //加了caddy-dynamicdns插件编译的才支持DDNS应用 + "dns_provider": { + "name": "duckdns", //可修改为其它caddy-dns插件(加了对应插件编译的才支持) + "api_token": "b8a33cc1-3333-2222-a1e6-b049bf07988f" //修改为对应caddy-dns插件的token + } + "domains": { + "xdddns.duckdns.org": ["@"] //xdddns.duckdns.org修改为注册的域名。@表示引用区域本身,若注册的域名为根域名,关联其二级域名用其前缀替换@即可。 + } + }, +//........<省略>........ + } +} diff --git a/Caddy(Other Configuration)/README.md b/Caddy(Other Configuration)/README.md new file mode 100644 index 00000000000..e4e83dc9fbc --- /dev/null +++ b/Caddy(Other Configuration)/README.md @@ -0,0 +1,43 @@ +一、回落后由 Caddy 分流到不同网站的配置方法 + +此方法解决 Xray 前置监听 443 后不影响先前 Caddy 前置时不同域名访问不同网站问题,配置见 shunt_caddy.json 或 shunt_Caddyfile 示例。 + +注意: + +1、若不同域名没有使用通配符证书,那么还需要在 Xray 中并列配置多个域名对应的证书及密钥。 + +2、此回落到不同网站是回落后由 Caddy 进行的 host(域名)分流。 + +3、也可以用 Caddy SNI、Nginx SNI、Xray fallbacks SNI 等分流来解决问题(不同方法,达到相同效果。),相关分流见各自配置示例。 + +二、Caddy 以 DNS-01 验证方式申请 TLS 证书的配置方法 + +Caddy 以 DNS-01 验证方式申请 TLS 证书,必须带对应 DNS API 插件。目前仅提供支持 cloudflare、dnspodcn(dnspod 中国版)、duckdns 三种常见插件配置示例。 + +注意: + +1、以 DNS-01 验证方式才支持通配符 TLS 证书申请。示例为通配符域名的 TLS 证书申请,可通配符域名、普通域名(含根域名)单一或组合申请(证书是各自分开的)。 + +2、申请免费 TLS 证书的域名不要超过五个,否则影响 TLS 证书的更新。 + +3、使用 duckdns 插件的挑战委托模式可间接实现无 DNS API 插件的域名管理以 DNS-01 验证方式申请 TLS 证书。 + +4、挑战委托模式最早由 duckdns 插件专属支持,后 Caddy 通用支持了(目前 Caddyfile 支持不完全)。其它插件不推荐配置此应用:A、其它插件使用此模式需要两个根域名;其中一个域名仅用它二级域名来中间关联,极大浪费。 B、目前其它插件 Caddyfile 配置挑战委托模式很不方便,无对应全局配置参数。 + +5、Cloudflare 已不支持后缀为 tk、ml、cf、ga、gq 的免费域名以 DNS-01 验证方式申请 TLS 证书了。可以参考上 duckdns 插件的挑战委托模式间接实现以 DNS-01 验证方式申请 TLS 证书。 + +三、caddy-events-exec 插件应用配置方法 + +以 caddy-events-exec 插件实现 TLS 证书自动更新后就执行重启相关程序来重载更新后的 TLS 证书,配置见 events-exec_caddy.json 或 events-exec_Caddyfile 示例。 + +四、Caddy 使用外部 TLS 证书的配置方法 + +Caddy 使用非自己内置 ACME 客户端提供的 TLS 证书时,其配置见 outside_caddy.json 或 outside_Caddyfile 示例。 + +五、Caddy 网盘应用配置方法 + +以 caddy-webdav 插件及文件服务应用打造不同的网盘应用(服务端),配置见 webdav_caddy.json 或 webdav_Caddyfile 示例。 + +六、Caddy DDNS 客户端配置方法 + +Caddy 使用 caddy-dynamicdns 插件及对应的 caddy-dns 插件实现对应的 DDNS 客户端应用。基本配置见 DDNS_caddy.json 或 DDNS_Caddyfile 示例,详细配置见 caddy-dynamicdns 资源。 diff --git a/Caddy(Other Configuration)/cloudflare_Caddyfile b/Caddy(Other Configuration)/cloudflare_Caddyfile new file mode 100644 index 00000000000..cb000c88e25 --- /dev/null +++ b/Caddy(Other Configuration)/cloudflare_Caddyfile @@ -0,0 +1,31 @@ +#一、以反代为核心应用 +#原配置: +{ +#........<省略>........ + email your@email.com #修改为自己的电子邮箱(选配) +#........<省略>........ +} + +:443, xx.yy { #xx.yy修改为自己的域名。注意:逗号与域名之间有一个空格。 +#........<省略>........ + @host { + host xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + } +#........<省略>........ + +#以dns api方式申请tls证书(以上配置修改为如下): +{ +#........<省略>........ + email your@email.com #修改为自己的电子邮箱(选配) + acme_dns cloudflare e09062f1fd2545555fc8a15fceda2222 #换成你cloudflare的api token +#........<省略>........ +} + +:443, *.xx.yy { #*.xx.yy表示为通配符域名,修改为自己的域名。注意:逗号与域名之间有一个空格。 +#........<省略>........ + @host { + host *.xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名(根据实际调整,不严谨可直接修改为通配符域名。)。 + } +#........<省略>........ +#注意: +#1、Caddy采用DNS-01验证方式申请的证书与域名是一一对应的,不支持申请包含根域名的通配符TLS证书。 diff --git a/Caddy(Other Configuration)/cloudflare_caddy.json b/Caddy(Other Configuration)/cloudflare_caddy.json new file mode 100644 index 00000000000..bd9f66c7eac --- /dev/null +++ b/Caddy(Other Configuration)/cloudflare_caddy.json @@ -0,0 +1,156 @@ +//一、以反代或REALITY Vision为核心应用 +//原配置: +//........<省略>........ + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。(域名名称与数量以实际为准) + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } +//........<省略>........ + +//以dns api方式申请tls证书(以上配置修改为如下): +//........<省略>........ + "tls": { + "certificates": { + "automate": ["*.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。*.xx.yy表示为通配符域名,修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com", //修改为自己的电子邮箱(选配),与下一致。 + "challenges": { + "dns": { + "provider": { + "name": "cloudflare", + "api_token": "e09062f1fd2545555fc8a15fceda2222" //换成你cloudflare的api token,与下一致。 + } + } + } + }, + { + "module": "zerossl", + "email": "your@email.com", //修改为自己的电子邮箱(选配),与上一致。 + "challenges": { + "dns": { + "provider": { + "name": "cloudflare", + "api_token": "e09062f1fd2545555fc8a15fceda2222" //换成你cloudflare的api token,与上一致。 + } + } + } + }] + }] + } + } +//........<省略>........ +//注意: +//1、Caddy采用DNS-01验证方式申请的证书与域名是一一对应的,不支持申请包含根域名的通配符TLS证书。 + + +//二、以回落/分流或XTLS Vision为核心应用(无SNI分流) +//原配置: +//........<省略>........ + "tls": { + "certificates": { + "automate": ["xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。(域名名称与数量以实际为准) + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } +//........<省略>........ + +//以dns api方式申请tls证书(以上配置修改为如下): +//........<省略>........ + "tls": { + "certificates": { + "automate": ["*.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。*.xx.yy表示为通配符域名,修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com", //修改为自己的电子邮箱(选配) + "challenges": { + "dns": { + "provider": { + "name": "cloudflare", + "api_token": "e09062f1fd2545555fc8a15fceda2222" //换成你cloudflare的api token + } + } + } + }] + }] + } + } +//........<省略>........ +//注意: +//1、Caddy采用DNS-01验证方式申请的证书与域名是一一对应的,不支持申请包含根域名的通配符TLS证书。 +//2、从Let's Encrypt申请的通配符TLS证书在 “/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/wildcard_.xx.yy” 目录中。/home/tls为存放TLS证书的基本路径,xx.yy为根域名,目录根据域名变化。 +//3、从ZeroSSL申请的通配符TLS证书在 “/home/tls/certificates/acme.zerossl.com-v2-dv90/wildcard_.xx.yy” 目录中。/home/tls为存放TLS证书的基本路径,xx.yy为根域名,目录根据域名变化。 + + +//三、以SNI分流为核心应用 +//原配置: +//........<省略>........ + "tls": { + "certificates": { + "automate": ["zv.xx.yy","zt.xx.yy","zh.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。(域名名称与数量以实际为准) + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } +//........<省略>........ + +//以dns api方式申请tls证书(以上配置修改为如下): +//........<省略>........ + "tls": { + "certificates": { + "automate": ["*.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。*.xx.yy表示为通配符域名,修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com", //修改为自己的电子邮箱(选配) + "challenges": { + "dns": { + "provider": { + "name": "cloudflare", + "api_token": "e09062f1fd2545555fc8a15fceda2222" //换成你cloudflare的api token + } + } + } + }] + }] + } + } +//........<省略>........ +//注意: +//1、Caddy采用DNS-01验证方式申请的证书与域名是一一对应的,不支持申请包含根域名的通配符TLS证书。 +//2、从Let's Encrypt申请的通配符TLS证书在 “/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/wildcard_.xx.yy” 目录中。/home/tls为存放TLS证书的基本路径,xx.yy为根域名,目录根据域名变化。 +//3、从ZeroSSL申请的通配符TLS证书在 “/home/tls/certificates/acme.zerossl.com-v2-dv90/wildcard_.xx.yy” 目录中。/home/tls为存放TLS证书的基本路径,xx.yy为根域名,目录根据域名变化。 diff --git a/Caddy(Other Configuration)/dnspodcn_Caddyfile b/Caddy(Other Configuration)/dnspodcn_Caddyfile new file mode 100644 index 00000000000..49a805b9bcc --- /dev/null +++ b/Caddy(Other Configuration)/dnspodcn_Caddyfile @@ -0,0 +1,31 @@ +#一、以反代为核心应用 +#原配置: +{ +#........<省略>........ + email your@email.com #修改为自己的电子邮箱(选配) +#........<省略>........ +} + +:443, xx.yy { #xx.yy修改为自己的域名。注意:逗号与域名之间有一个空格。 +#........<省略>........ + @host { + host xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + } +#........<省略>........ + +#以dns api方式申请tls证书(以上配置修改为如下): +{ +#........<省略>........ + email your@email.com #修改为自己的电子邮箱(选配) + acme_dns dnspodcn 1232456 e09062f1fd2545555fc8a15fceda2222 #换成你dnspod.cn的DP_Id与DP_Key +#........<省略>........ +} + +:443, *.xx.yy { #*.xx.yy表示为通配符域名,修改为自己的域名。注意:逗号与域名之间有一个空格。 +#........<省略>........ + @host { + host *.xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名(根据实际调整,不严谨可直接修改为通配符域名。)。 + } +#........<省略>........ +#注意: +#1、Caddy采用DNS-01验证方式申请的证书与域名是一一对应的,不支持申请包含根域名的通配符TLS证书。 diff --git a/Caddy(Other Configuration)/dnspodcn_caddy.json b/Caddy(Other Configuration)/dnspodcn_caddy.json new file mode 100644 index 00000000000..b211151b7f6 --- /dev/null +++ b/Caddy(Other Configuration)/dnspodcn_caddy.json @@ -0,0 +1,168 @@ +//一、以反代或REALITY Vision为核心应用 +//原配置: +//........<省略>........ + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。(域名名称与数量以实际为准) + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } +//........<省略>........ + +//以dns api方式申请tls证书(以上配置修改为如下): +//........<省略>........ + "tls": { + "certificates": { + "automate": ["*.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。*.xx.yy表示为通配符域名,修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com", //修改为自己的电子邮箱(选配),与下一致。 + "challenges": { + "dns": { + "provider": { + "Language": "en", + "BaseURL": "https://dnsapi.cn", + "name": "dnspodcn", + "AppID": "1232456", //换成你dnspod.cn的DP_Id,与下一致。 + "AppToken": "e09062f1fd2545555fc8a15fceda2222" //换成你dnspod.cn的DP_Key,与下一致。 + } + } + } + }, + { + "module": "zerossl", + "email": "your@email.com", //修改为自己的电子邮箱(选配),与上一致。 + "challenges": { + "dns": { + "provider": { + "Language": "en", + "BaseURL": "https://dnsapi.cn", + "name": "dnspodcn", + "AppID": "1232456", //换成你dnspod.cn的DP_Id,与上一致。 + "AppToken": "e09062f1fd2545555fc8a15fceda2222" //换成你dnspod.cn的DP_Key,与上一致。 + } + } + } + }] + }] + } + } +//........<省略>........ +//注意: +//1、Caddy采用DNS-01验证方式申请的证书与域名是一一对应的,不支持申请包含根域名的通配符TLS证书。 + + +//二、以回落/分流或XTLS Vision为核心应用(无SNI分流) +//原配置: +//........<省略>........ + "tls": { + "certificates": { + "automate": ["xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。(域名名称与数量以实际为准) + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } +//........<省略>........ + +//以dns api方式申请tls证书(以上配置修改为如下): +//........<省略>........ + "tls": { + "certificates": { + "automate": ["*.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。*.xx.yy表示为通配符域名,修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com", //修改为自己的电子邮箱(选配) + "challenges": { + "dns": { + "provider": { + "Language": "en", + "BaseURL": "https://dnsapi.cn", + "name": "dnspodcn", + "AppID": "1232456", //换成你dnspod.cn的DP_Id + "AppToken": "e09062f1fd2545555fc8a15fceda2222" //换成你dnspod.cn的DP_Key + } + } + } + }] + }] + } + } +//........<省略>........ +//注意: +//1、Caddy采用DNS-01验证方式申请的证书与域名是一一对应的,不支持申请包含根域名的通配符TLS证书。 +//2、从Let's Encrypt申请的通配符TLS证书在 “/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/wildcard_.xx.yy” 目录中。/home/tls为存放TLS证书的基本路径,xx.yy为根域名,目录根据域名变化。 +//3、从ZeroSSL申请的通配符TLS证书在 “/home/tls/certificates/acme.zerossl.com-v2-dv90/wildcard_.xx.yy” 目录中。/home/tls为存放TLS证书的基本路径,xx.yy为根域名,目录根据域名变化。 + + +//三、以SNI分流为核心应用 +//原配置: +//........<省略>........ + "tls": { + "certificates": { + "automate": ["zv.xx.yy","zt.xx.yy","zh.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。(域名名称与数量以实际为准) + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } +//........<省略>........ + +//以dns api方式申请tls证书(以上配置修改为如下): +//........<省略>........ + "tls": { + "certificates": { + "automate": ["*.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。*.xx.yy表示为通配符域名,修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com", //修改为自己的电子邮箱(选配) + "challenges": { + "dns": { + "provider": { + "Language": "en", + "BaseURL": "https://dnsapi.cn", + "name": "dnspodcn", + "AppID": "1232456", //换成你dnspod.cn的DP_Id + "AppToken": "e09062f1fd2545555fc8a15fceda2222" //换成你dnspod.cn的DP_Key + } + } + } + }] + }] + } + } +//........<省略>........ +//注意: +//1、Caddy采用DNS-01验证方式申请的证书与域名是一一对应的,不支持申请包含根域名的通配符TLS证书。 +//2、从Let's Encrypt申请的通配符TLS证书在 “/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/wildcard_.xx.yy” 目录中。/home/tls为存放TLS证书的基本路径,xx.yy为根域名,目录根据域名变化。 +//3、从ZeroSSL申请的通配符TLS证书在 “/home/tls/certificates/acme.zerossl.com-v2-dv90/wildcard_.xx.yy” 目录中。/home/tls为存放TLS证书的基本路径,xx.yy为根域名,目录根据域名变化。 diff --git a/Caddy(Other Configuration)/duckdns_Caddyfile b/Caddy(Other Configuration)/duckdns_Caddyfile new file mode 100644 index 00000000000..f5324f8bcdb --- /dev/null +++ b/Caddy(Other Configuration)/duckdns_Caddyfile @@ -0,0 +1,36 @@ +#一、以反代为核心应用 +#原配置: +{ +#........<省略>........ + email your@email.com #修改为自己的电子邮箱(选配) +#........<省略>........ +} + +:443, xx.yy { #xx.yy修改为自己的域名。注意:逗号与域名之间有一个空格。 +#........<省略>........ + @host { + host xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + } +#........<省略>........ + +#以dns api方式申请tls证书(以上配置修改为如下): +{ +#........<省略>........ + email your@email.com #修改为自己的电子邮箱(选配) + acme_dns duckdns b8a33cc1-1111-2222-3333-b049bf07988f { #换成你duckdns的token + override_domain zz.duckdns.org #换成你duckdns中配置的DDNS域名(二级域名) + } +#........<省略>........ +} + +:443, *.xx.yy { #*.xx.yy表示为通配符域名,修改为自己的域名。注意:逗号与域名之间有一个空格。 +#........<省略>........ + @host { + host *.xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名(根据实际调整,不严谨可直接修改为通配符域名。)。 + } +#........<省略>........ +#注意: +#1、Caddy采用DNS-01验证方式申请的证书与域名是一一对应的,不支持申请包含根域名的通配符TLS证书。 +#2、此配置为挑战委托模式,实现无DNS-01验证方式的域名委托给有DNS-01验证方式的域名申请TLS证书。 +#3、挑战委托模式实现条件:*.xx.yy关联zz.duckdns.org(CNAME记录),zz.duckdns.org关联VPS IP(A记录)。 +#4、若不使用挑战委托模式:删除"override_domain": "zz.duckdns.org"这条参数及同步删除"api_token"参数末尾逗号,对应域名修改为你在duckdns中配置的DDNS域名。 diff --git a/Caddy(Other Configuration)/duckdns_caddy.json b/Caddy(Other Configuration)/duckdns_caddy.json new file mode 100644 index 00000000000..ba283286c7d --- /dev/null +++ b/Caddy(Other Configuration)/duckdns_caddy.json @@ -0,0 +1,169 @@ +//一、以反代或REALITY Vision为核心应用 +//原配置: +//........<省略>........ + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。(域名名称与数量以实际为准) + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } +//........<省略>........ + +//以dns api方式申请tls证书(以上配置修改为如下): +//........<省略>........ + "tls": { + "certificates": { + "automate": ["*.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。*.xx.yy表示为通配符域名,修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com", //修改为自己的电子邮箱(选配),与下一致。 + "challenges": { + "dns": { + "provider": { + "name": "duckdns", + "api_token": "b8a33cc1-1111-2222-3333-b049bf07988f", //换成你duckdns的token,与下一致。 + "override_domain": "zz.duckdns.org" //换成你在duckdns中配置的一个二级域名(DDNS域名),与下一致。 + } + } + } + }, + { + "module": "zerossl", + "email": "your@email.com", //修改为自己的电子邮箱(选配),与上一致。 + "challenges": { + "dns": { + "provider": { + "name": "duckdns", + "api_token": "b8a33cc1-1111-2222-3333-b049bf07988f", //换成你duckdns的token,与上一致。 + "override_domain": "zz.duckdns.org" //换成你在duckdns中配置的一个二级域名(DDNS域名),与上一致。 + } + } + } + }] + }] + } + } +//........<省略>........ +//注意: +//1、Caddy采用DNS-01验证方式申请的证书与域名是一一对应的,不支持申请包含根域名的通配符TLS证书。 +//2、此配置为挑战委托模式,实现无DNS-01验证方式的域名委托给有DNS-01验证方式的域名申请TLS证书。 +//3、挑战委托模式实现条件:*.xx.yy关联zz.duckdns.org(CNAME记录),zz.duckdns.org关联VPS IP(A记录)。 +//4、若不使用挑战委托模式:删除"override_domain": "zz.duckdns.org"这条参数及同步删除"api_token"参数末尾逗号,对应域名修改为你在duckdns中配置的DDNS域名。 + + +//二、以回落/分流或XTLS Vision为核心应用(无SNI分流) +//原配置: +//........<省略>........ + "tls": { + "certificates": { + "automate": ["xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。(域名名称与数量以实际为准) + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } +//........<省略>........ + +//以dns api方式申请tls证书(以上配置修改为如下): +//........<省略>........ + "tls": { + "certificates": { + "automate": ["*.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。*.xx.yy表示为通配符域名,修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com", //修改为自己的电子邮箱(选配) + "challenges": { + "dns": { + "provider": { + "name": "duckdns", + "api_token": "b8a33cc1-1111-2222-3333-b049bf07988f", //换成你duckdns的token + "override_domain": "zz.duckdns.org" //换成你在duckdns中配置的一个二级域名(DDNS域名) + } + } + } + }] + }] + } + } +//........<省略>........ +//注意: +//1、Caddy采用DNS-01验证方式申请的证书与域名是一一对应的,不支持申请包含根域名的通配符TLS证书。 +//2、此配置为挑战委托模式,实现无DNS-01验证方式的域名委托给有DNS-01验证方式的域名申请TLS证书。 +//3、挑战委托模式实现条件:*.xx.yy关联zz.duckdns.org(CNAME记录),zz.duckdns.org关联VPS IP(A记录)。 +//4、若不使用挑战委托模式:删除"override_domain": "zz.duckdns.org"这条参数及同步删除"api_token"参数末尾逗号,对应域名修改为你在duckdns中配置的DDNS域名。 +//5、从Let's Encrypt申请的通配符TLS证书在 “/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/wildcard_.xx.yy” 目录中。/home/tls为存放TLS证书的基本路径,xx.yy为根域名,目录根据域名变化。 +//6、从ZeroSSL申请的通配符TLS证书在 “/home/tls/certificates/acme.zerossl.com-v2-dv90/wildcard_.xx.yy” 目录中。/home/tls为存放TLS证书的基本路径,xx.yy为根域名,目录根据域名变化。 + + +//三、以SNI分流为核心应用 +//原配置: +//........<省略>........ + "tls": { + "certificates": { + "automate": ["zv.xx.yy","zt.xx.yy","zh.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。(域名名称与数量以实际为准) + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } +//........<省略>........ + +//以dns api方式申请tls证书(以上配置修改为如下): +//........<省略>........ + "tls": { + "certificates": { + "automate": ["*.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。*.xx.yy表示为通配符域名,修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com", //修改为自己的电子邮箱(选配) + "challenges": { + "dns": { + "provider": { + "name": "duckdns", + "api_token": "b8a33cc1-1111-2222-3333-b049bf07988f", //换成你duckdns的token + "override_domain": "zz.duckdns.org" //换成你在duckdns中配置的一个二级域名(DDNS域名) + } + } + } + }] + }] + } + } +//........<省略>........ +//注意: +//1、Caddy采用DNS-01验证方式申请的证书与域名是一一对应的,不支持申请包含根域名的通配符TLS证书。 +//2、此配置为挑战委托模式,实现无DNS-01验证方式的域名委托给有DNS-01验证方式的域名申请TLS证书。 +//3、挑战委托模式实现条件:*.xx.yy关联zz.duckdns.org(CNAME记录),zz.duckdns.org关联VPS IP(A记录)。 +//4、若不使用挑战委托模式:删除"override_domain": "zz.duckdns.org"这条参数及同步删除"api_token"参数末尾逗号,对应域名修改为你在duckdns中配置的DDNS域名。 +//5、从Let's Encrypt申请的通配符TLS证书在 “/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/wildcard_.xx.yy” 目录中。/home/tls为存放TLS证书的基本路径,xx.yy为根域名,目录根据域名变化。 +//6、从ZeroSSL申请的通配符TLS证书在 “/home/tls/certificates/acme.zerossl.com-v2-dv90/wildcard_.xx.yy” 目录中。/home/tls为存放TLS证书的基本路径,xx.yy为根域名,目录根据域名变化。 diff --git a/Caddy(Other Configuration)/events-exec_Caddyfile b/Caddy(Other Configuration)/events-exec_Caddyfile new file mode 100644 index 00000000000..f83eca9dfaa --- /dev/null +++ b/Caddy(Other Configuration)/events-exec_Caddyfile @@ -0,0 +1,53 @@ +#caddy-events-exec插件应用 +#原配置: +{ +#........<省略>........ +} +#........<省略>........ + +#1、重启/重载单个程序 +#原配置修改为如下(Caddy用户拥有root权限): +{ +#........<省略>........ + events { + on cert_obtained exec systemctl restart hysteria #可以调整为其它程序 + } +} +#........<省略>........ + +#原配置修改为如下(Caddy用户拥有sudo权限): +{ +#........<省略>........ + events { + on cert_obtained exec sudo systemctl restart hysteria #可以调整为其它程序 + } +} +#........<省略>........ + +#2、重启/重载多个程序 +#原配置修改为如下(Caddy用户拥有root权限): +{ +#........<省略>........ + events { + on cert_obtained exec systemctl reload nginx #可以调整为其它程序 + on cert_obtained exec systemctl restart hysteria #可以调整为其它程序 + } +} +#........<省略>........ + +#原配置修改为如下(Caddy用户拥有sudo权限): +{ +#........<省略>........ + events { + on cert_obtained exec sudo systemctl reload nginx #可以调整为其它程序 + on cert_obtained exec sudo systemctl restart hysteria #可以调整为其它程序 + } +} +#........<省略>........ +#备注: +#1、本示例实现了TLS证书自动更新后就联动执行重启/重载相关程序来重载更新后的TLS证书。 +#2、本示例sudo权限用户重启/重载相关程序需要取消密码验证,其配置可参考如下(Caddy使用nodody用户): +#1)、nobody ALL=NOPASSWD:/bin/systemctl restart hysteria (表示nobody用户使用sudo权限重启hysteria不需要密码) +#2)、nobody ALL=NOPASSWD:/bin/systemctl reload nginx (表示nobody用户使用sudo权限重载Nginx不需要密码) +#3)、nobody ALL=NOPASSWD:/bin/systemctl restart X,/bin/systemctl restart Y (表示nobody用户使用sudo权限重启X与Y都不需要密码) +#4)、nobody ALL=NOPASSWD:/bin/systemctl restart [a-zA-Z]* (表示nobody用户使用sudo权限重启所有程序都不需要密码。不推荐。) diff --git a/Caddy(Other Configuration)/events-exec_caddy.json b/Caddy(Other Configuration)/events-exec_caddy.json new file mode 100644 index 00000000000..b59a1711dad --- /dev/null +++ b/Caddy(Other Configuration)/events-exec_caddy.json @@ -0,0 +1,94 @@ +//caddy-events-exec插件应用 +//原配置: +//........<省略>........ + "tls": { +//........<省略>........ + } +//........<省略>........ + +//1、重启/重载单个程序 +//原配置修改为如下(Caddy用户拥有root权限): +//........<省略>........ + "tls": { +//........<省略>........ + }, + "events": { + "subscriptions": [{ + "events": ["cert_obtained"], + "handlers": [{ + "handler": "exec", + "command": "systemctl", + "args": ["restart","hysteria"] //可以调整为其它程序 + }] + }] + } +//........<省略>........ + +//原配置修改为如下(Caddy用户拥有sudo权限): +//........<省略>........ + "tls": { +//........<省略>........ + }, + "events": { + "subscriptions": [{ + "events": ["cert_obtained"], + "handlers": [{ + "handler": "exec", + "command": "sudo", + "args": ["systemctl","restart","hysteria"] //可以调整为其它程序 + }] + }] + } +//........<省略>........ + +//2、重启/重载多个程序 +//原配置修改为如下(Caddy用户拥有root权限): +//........<省略>........ + "tls": { +//........<省略>........ + }, + "events": { + "subscriptions": [{ + "events": ["cert_obtained"], + "handlers": [{ + "handler": "exec", + "command": "systemctl", + "args": ["reload","nginx"] //可以调整为其它程序 + }, + { + "handler": "exec", + "command": "systemctl", + "args": ["restart","hysteria"] //可以调整为其它程序 + }] + }] + } +//........<省略>........ + +//原配置修改为如下(Caddy用户拥有sudo权限): +//........<省略>........ + "tls": { +//........<省略>........ + }, + "events": { + "subscriptions": [{ + "events": ["cert_obtained"], + "handlers": [{ + "handler": "exec", + "command": "sudo", + "args": ["systemctl","reload","nginx"] //可以调整为其它程序 + }, + { + "handler": "exec", + "command": "sudo", + "args": ["systemctl","restart","hysteria"] //可以调整为其它程序 + }] + }] + } +//........<省略>........ +//备注: +//1、本示例实现了TLS证书自动更新后就联动执行重启/重载相关程序来重载更新后的TLS证书。 +//2、本示例sudo权限用户重启/重载相关程序需要取消密码验证,其配置可参考如下(Caddy使用nodody用户): +//1)、nobody ALL=NOPASSWD:/bin/systemctl restart hysteria (表示nobody用户使用sudo权限重启hysteria不需要密码) +//2)、nobody ALL=NOPASSWD:/bin/systemctl reload nginx (表示nobody用户使用sudo权限重载Nginx不需要密码) +//3)、nobody ALL=NOPASSWD:/bin/systemctl restart X,/bin/systemctl restart Y (表示nobody用户使用sudo权限重启X与Y都不需要密码) +//4)、nobody ALL=NOPASSWD:/bin/systemctl restart [a-zA-Z]* (表示nobody用户使用sudo权限重启所有程序都不需要密码。不推荐。) diff --git a/Caddy(Other Configuration)/outside_Caddyfile b/Caddy(Other Configuration)/outside_Caddyfile new file mode 100644 index 00000000000..570e3607a0a --- /dev/null +++ b/Caddy(Other Configuration)/outside_Caddyfile @@ -0,0 +1,18 @@ +#一、以反代为核心应用 +#原配置: +#........<省略>........ + email your@email.com #修改为自己的电子邮箱(选配) +#........<省略>........ + +:443, xx.yy { #xx.yy修改为自己的域名。注意:逗号与域名之间有一个空格。 + tls { +#........<省略>........ + +#以上配置修改为如下: +#........<省略>........ +#.....<删除此条参数>... +#........<省略>........ + +:443 { + tls /home/tls/xx.yy/xx.yy.crt /home/tls/xx.yy/xx.yy.key { #换成自己的证书与密钥,绝对路径。 +#........<省略>........ diff --git a/Caddy(Other Configuration)/outside_caddy.json b/Caddy(Other Configuration)/outside_caddy.json new file mode 100644 index 00000000000..2b54fbea52b --- /dev/null +++ b/Caddy(Other Configuration)/outside_caddy.json @@ -0,0 +1,187 @@ +//一、以反代或REALITY Vision为核心应用 +//原配置: +//........<省略>........ + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["z2.xx.yy"] //限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], +//........<省略>........ + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } +//........<省略>........ + +//以上配置修改为如下: +//........<省略>........ + "tls_connection_policies": [{ + "certificate_selection": { + "any_tag": ["tls01"] //关联对应证书标签 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "certificate_selection": { + "any_tag": ["tls02"] //关联对应证书标签 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], +//........<省略>........ + "tls": { + "certificates": { + "load_files": [{ + "certificate": "/home/tls/z1.xx.yy/z1.xx.yy.crt", //换成自己的证书,绝对路径。 + "key": "/home/tls/z1.xx.yy/z1.xx.yy.key", //换成自己的密钥,绝对路径。 + "tags": ["tls01"] //关联对应证书标签 + }, + { + "certificate": "/home/tls/z2.xx.yy/z2.xx.yy.crt", //换成自己的证书,绝对路径。 + "key": "/home/tls/z2.xx.yy/z2.xx.yy.key", //换成自己的密钥,绝对路径。 + "tags": ["tls02"] //关联对应证书标签 + }] //若使用通配符证书或SAN证书合并一组即可。 + } + } +//........<省略>........ + + +//二、以回落/分流或XTLS Vision为核心应用(无SNI分流) +//原配置: +//........<省略>........ + "storage": { + "module": "file_system", + "root": "/home/tls" //存放TLS证书的基本路径 + }, +//........<省略>........ + "tls": { + "certificates": { + "automate": ["xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } +//........<省略>........ + +//以上配置修改为如下: +//........<省略>........ +//.....<删除此部分>..... +//........<省略>........ +//.....<删除此部分>..... +//........<省略>........ + + +//三、以SNI分流为核心应用 +//原配置: +//........<省略>........ + "storage": { + "module": "file_system", + "root": "/home/tls" //存放TLS证书的基本路径 + }, +//........<省略>........ + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名访问,修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["zv.xx.yy","zh.xx.yy"] //限定域名访问,修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], +//........<省略>........ + "tls": { + "certificates": { + "automate": ["zv.xx.yy","zt.xx.yy","zh.xx.yy","z1.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } +//........<省略>........ + +//以上配置修改为如下: +//........<省略>........ +//.....<删除此部分>..... +//........<省略>........ + "tls_connection_policies": [{ + "certificate_selection": { + "any_tag": ["tls01"] //关联对应证书标签 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "certificate_selection": { + "any_tag": ["tls02","tls03"] //关联对应证书标签 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], +//........<省略>........ + "tls": { + "certificates": { + "load_files": [{ + "certificate": "/home/tls/z1.xx.yy/z1.xx.yy.crt", //换成自己的证书,绝对路径。 + "key": "/home/tls/z1.xx.yy/z1.xx.yy.key", //换成自己的密钥,绝对路径。 + "tags": ["tls01"] //关联对应证书标签 + }, + { + "certificate": "/home/tls/zv.xx.yy/zv.xx.yy.crt", //换成自己的证书,绝对路径。 + "key": "/home/tls/zv.xx.yy/zv.xx.yy.key", //换成自己的密钥,绝对路径。 + "tags": ["tls02"] //关联对应证书标签 + }, + { + "certificate": "/home/tls/zh.xx.yy/zh.xx.yy.crt", //换成自己的证书,绝对路径。 + "key": "/home/tls/zh.xx.yy/zh.xx.yy.key", //换成自己的密钥,绝对路径。 + "tags": ["tls03"] //关联对应证书标签 + }] //若使用通配符证书或SAN证书合并一组即可。 + } + } +//........<省略>........ diff --git a/Caddy(Other Configuration)/shunt_Caddyfile b/Caddy(Other Configuration)/shunt_Caddyfile new file mode 100644 index 00000000000..99ab24556df --- /dev/null +++ b/Caddy(Other Configuration)/shunt_Caddyfile @@ -0,0 +1,42 @@ +#回落分流到不同网站配置 +#原配置: +#........<省略>........ + @host { + host xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + } + route @host { + header { + Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" #启用HSTS + } + file_server { + root /var/www/html #修改为自己存放的WEB文件路径 + } + } +} + +#以上配置修改为如下:(示例仅配置了两个网站/域名的回落分流;如需要多个网站/域名,增加对应参数即可。) +#........<省略>........ + @host1 { + host za.xx.yy #修改为分流的域名 + } + route @host1 { + header { + Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" #启用HSTS + } + file_server { + root /var/www/za #修改为自己存放的WEB文件路径 + } + } + + @host2 { + host zb.xx.yy #修改为分流的域名 + } + route @host2 { + header { + Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" #启用HSTS + } + file_server { + root /var/www/zb #修改为自己存放的WEB文件路径 + } + } +} diff --git a/Caddy(Other Configuration)/shunt_caddy.json b/Caddy(Other Configuration)/shunt_caddy.json new file mode 100644 index 00000000000..70533647de5 --- /dev/null +++ b/Caddy(Other Configuration)/shunt_caddy.json @@ -0,0 +1,80 @@ +//回落分流到不同网站配置 +//原配置: +//........<省略>........ + "routes": [{ //或者其它应用后{开始 + "match": [{ + "host": ["xx.yy"] //限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + }], + "handle": [{ + "handler": "subroute", + "routes": [{ + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }] + }, + { + "handle": [{ + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }] + }] + }], +//........<省略>........ + +//以上配置修改为如下:(示例仅配置了两个网站/域名的回落分流;如需要多个网站/域名,增加对应参数即可。) +//........<省略>........ + "routes": [{ //或者其它应用后{开始 + "match": [{ + "host": ["za.xx.yy"] //修改为分流的域名 + }], + "handle": [{ + "handler": "subroute", + "routes": [{ + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }] + }, + { + "handle": [{ + "handler": "file_server", + "root": "/var/www/za" //修改为自己存放的WEB文件路径 + }] + }] + }] + }, + { + "match": [{ + "host": ["zb.xx.yy"] //修改为分流的域名 + }], + "handle": [{ + "handler": "subroute", + "routes": [{ + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }] + }, + { + "handle": [{ + "handler": "file_server", + "root": "/var/www/zb" //修改为自己存放的WEB文件路径 + }] + }] + }] + }], +//........<省略>........ diff --git a/Caddy(Other Configuration)/webdav_Caddyfile b/Caddy(Other Configuration)/webdav_Caddyfile new file mode 100644 index 00000000000..a8951a69474 --- /dev/null +++ b/Caddy(Other Configuration)/webdav_Caddyfile @@ -0,0 +1,84 @@ +#网盘应用配置 +#配置一 +#........<省略>........ + @notget { + not method GET + } + route @notget { + basicauth { #可以设置多组用户及密码 + user JDJhJDE0JGMzclpVMkU4bVhMRVRXY0o2a2pmMnVGUDNqcGxGZ3ByY1ZTMEVDbi80N1M0NE93NUZXZXNl #验证用户与密码(示例为password的哈希密码),修改为自己的。 + } + webdav { + root /home/webdav #修改为WebDAV服务器存放文件路径 + } + } +#........<省略>........ +#备注: +#1、本配置适合为个人或特定人群提供基本的文件管理服务。仅支持WebDAV客户端(有验证)浏览文件,可删除、上传、修改等。 +#2、在本人示例的回落或代理网站配置块之前插增加上边配置块,就可实现WebDAV服务器与回落或代理网站共存。 +#3、修改/home/webdav的目录权限为0777,以便客户端具有写入及删除文件权限。 +#4、basicauth中密码必须使用哈希密码,可用caddy hash-password --plaintext 命令把普通密码转化为哈希密码并输出。例如:/usr/bin/caddy hash-password --plaintext password + +#配置二 +#........<省略>........ + @host { + host zz.xx.yy #限定网盘应用访问,修改为对应域名。 + } + route @host { + root * /home/webdav #修改为文件管理服务存放文件路径 + @get { + method GET + } + header @get { + Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" #启用HSTS + } + file_server @get { + browse + } + basicauth { #可以设置多组用户及密码 + user JDJhJDE0JGMzclpVMkU4bVhMRVRXY0o2a2pmMnVGUDNqcGxGZ3ByY1ZTMEVDbi80N1M0NE93NUZXZXNl #验证用户与密码(示例为password的哈希密码),修改为自己的。 + } + webdav + } +#........<省略>........ +#备注: +#1、本配置适合为普通人群提供文件分享及专业的文件管理服务。 +#1)、支持WEB登录(无验证)浏览文件,可下载、音视频文件在线播放等。 +#2)、支持WebDAV客户端(有验证)浏览文件,可删除、上传、修改等。 +#2、本人示例的回落或代理网站配置块都可直接替换为上边配置块,伪装网站改为文件服务器网站。(不推荐) +#3、在本人示例的回落或代理网站配置块之前增加上边配置块,同步调整证书与域名相关就可实现文件服务器网站与回落或代理网站共存。 +#4、在本人SNI分流示例中增加含上述配置块的不同端口站点,同步调整SNI分流配置、证书与域名相关就可实现文件服务器网站与代理网站共存。另删除上‘限定网盘应用访问’配置,SNI分流已配置(不必再次配置)。 +#5、修改/home/webdav的目录权限为0777,以便客户端具有写入及删除文件权限。 +#6、basicauth中密码必须使用哈希密码,可用caddy hash-password --plaintext 命令把普通密码转化为哈希密码并输出。例如:/usr/bin/caddy hash-password --plaintext password + +#配置三 +#........<省略>........ + @host2 { + host zz.xx.yy #限定网盘应用访问,修改为对应域名。 + } + route @host2 { + root * /home/webdav #修改为文件管理服务存放文件路径 + @get { + method GET + } + header @get { + Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" #启用HSTS + } + basicauth { #可以设置多组用户及密码 + user JDJhJDE0JGMzclpVMkU4bVhMRVRXY0o2a2pmMnVGUDNqcGxGZ3ByY1ZTMEVDbi80N1M0NE93NUZXZXNl #验证用户与密码(示例为password的哈希密码),修改为自己的。 + } + file_server @get { + browse + } + webdav + } +#........<省略>........ +#备注: +#1、本配置适合为个人或特定人群提供专业的文件管理服务。 +#1)、支持WEB登录(有验证)浏览文件,可下载、音视频文件在线播放等。 +#2)、支持WebDAV客户端(有验证)浏览文件,可删除、上传、修改等。 +#3)、WEB登录与WebDAV客户端,两者用户及密码通用。 +#2、在本人示例的回落或代理网站配置块之前增加上边配置块,同步调整证书与域名相关就可实现文件服务器网站与回落或代理网站共存。 +#3、在本人SNI分流示例中增加含上述配置块的不同端口站点,同步调整SNI分流配置、证书与域名相关就可实现文件服务器网站与代理网站共存。另删除上‘限定网盘应用访问’配置,SNI分流已配置(不必再次配置)。 +#4、修改/home/webdav的目录权限为0777,以便客户端具有写入及删除文件权限。 +#5、basicauth中密码必须使用哈希密码,可用caddy hash-password --plaintext 命令把普通密码转化为哈希密码并输出。例如:/usr/bin/caddy hash-password --plaintext password diff --git a/Caddy(Other Configuration)/webdav_caddy.json b/Caddy(Other Configuration)/webdav_caddy.json new file mode 100644 index 00000000000..85a8256bbb6 --- /dev/null +++ b/Caddy(Other Configuration)/webdav_caddy.json @@ -0,0 +1,170 @@ +//网盘应用配置 +//配置一 +//........<省略>........ + { + "match": [{ + "not": [{ + "method": ["GET"] + }] + }], + "handle": [{ + "handler": "authentication", + "providers": { + "http_basic": { + "hash": { + "algorithm": "bcrypt" + }, + "accounts": [{ //可以配置多组用户及密码 + "username": "user", //验证用户,修改为自己的。 + "password": "JDJhJDE0JGMzclpVMkU4bVhMRVRXY0o2a2pmMnVGUDNqcGxGZ3ByY1ZTMEVDbi80N1M0NE93NUZXZXNl" //验证密码(示例为password的哈希密码),修改为自己的。 + }], + "hash_cache": {} + } + } + }, + { + "handler": "webdav", + "root": "/home/webdav" //修改为WebDAV服务器存放文件路径 + }] + }, +//........<省略>........ +//备注: +//1、本配置适合为个人或特定人群提供基本的文件管理服务。仅支持WebDAV客户端(有验证)浏览文件,可删除、上传、修改等。 +//2、在本人示例的回落或代理网站配置块之前插增加上边配置块,就可实现WebDAV服务器与回落或代理网站共存。 +//3、修改/home/webdav的目录权限为0777,以便客户端具有写入及删除文件权限。 +//4、authentication中密码必须使用哈希密码,可用caddy hash-password --plaintext 命令把普通密码转化为哈希密码并输出。例如:/usr/bin/caddy hash-password --plaintext password + +//配置二 +//........<省略>........ + { + "match": [{ + "host": ["zz.xx.yy"] //限定网盘应用访问,修改为对应域名。 + }], + "handle": [{ + "handler": "subroute", + "routes": [{ + "handle": [{ + "handler": "vars", + "root": "/home/webdav" //修改为文件管理服务存放文件路径 + }] + }, + { + "match": [{ + "method": ["GET"] + }], + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "browse": {} + }] + }, + { + "handle": [{ + "handler": "authentication", + "providers": { + "http_basic": { + "hash": { + "algorithm": "bcrypt" + }, + "accounts": [{ //可以设置多组用户及密码 + "username": "user", //验证用户,修改为自己的。 + "password": "JDJhJDE0JGMzclpVMkU4bVhMRVRXY0o2a2pmMnVGUDNqcGxGZ3ByY1ZTMEVDbi80N1M0NE93NUZXZXNl" //验证密码(示例为password的哈希密码),修改为自己的。 + }], + "hash_cache": {} + } + } + }, + { + "handler": "webdav" + }] + }] + }] + }], //仅增加此配置块,‘}]’调整为‘},’。 +//........<省略>........ +//备注: +//1、本配置适合为普通人群提供文件分享及专业的文件管理服务。 +//1)、支持WEB登录(无验证)浏览文件,可下载、音视频文件在线播放等。 +//2)、支持WebDAV客户端(有验证)浏览文件,可删除、上传、修改等。 +//2、本人示例的回落或代理网站配置块都可直接替换为上边配置块,伪装网站改为文件服务器网站。(不推荐) +//3、在本人示例的回落或代理网站配置块之前增加上边配置块,同步调整证书与域名相关就可实现文件服务器网站与回落或代理网站共存。 +//4、在本人SNI分流示例中增加含上述配置块的不同端口站点,同步调整SNI分流配置、证书与域名相关就可实现文件服务器网站与代理网站共存。另删除上‘限定网盘应用访问’配置,SNI分流已配置(不必再次配置)。 +//5、修改/home/webdav的目录权限为0777,以便客户端具有写入及删除文件权限。 +//6、authentication中密码必须使用哈希密码,可用caddy hash-password --plaintext 命令把普通密码转化为哈希密码并输出。例如:/usr/bin/caddy hash-password --plaintext password + +//配置三 +//........<省略>........ + { + "match": [{ + "host": ["zz.xx.yy"] //限定网盘应用访问,修改为对应域名。 + }], + "handle": [{ + "handler": "subroute", + "routes": [{ + "handle": [{ + "handler": "vars", + "root": "/home/webdav" //修改为文件管理服务存放文件路径 + }] + }, + { + "match": [{ + "method": ["GET"] + }], + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }] + }, + { + "handle": [{ + "handler": "authentication", + "providers": { + "http_basic": { + "hash": { + "algorithm": "bcrypt" + }, + "accounts": [{ //可以设置多组用户及密码 + "username": "user", //验证用户,修改为自己的。 + "password": "JDJhJDE0JGMzclpVMkU4bVhMRVRXY0o2a2pmMnVGUDNqcGxGZ3ByY1ZTMEVDbi80N1M0NE93NUZXZXNl" //验证密码(示例为password的哈希密码),修改为自己的。 + }], + "hash_cache": {} + } + } + }] + }, + { + "match": [{ + "method": ["GET"] + }], + "handle": [{ + "handler": "file_server", + "browse": {} + }] + }, + { + "handle": [{ + "handler": "webdav" + }] + }] + }] + }], //仅增加此配置块,‘}]’调整为‘},’。 +//........<省略>........ +//备注: +//1、本配置适合为个人或特定人群提供专业的文件管理服务。 +//1)、支持WEB登录(有验证)浏览文件,可下载、音视频文件在线播放等。 +//2)、支持WebDAV客户端(有验证)浏览文件,可删除、上传、修改等。 +//3)、WEB登录与WebDAV客户端,两者用户及密码通用。 +//2、在本人示例的回落或代理网站配置块之前增加上边配置块,同步调整证书与域名相关就可实现文件服务器网站与回落或代理网站共存。 +//3、在本人SNI分流示例中增加含上述配置块的不同端口站点,同步调整SNI分流配置、证书与域名相关就可实现文件服务器网站与代理网站共存。另删除上‘限定网盘应用访问’配置,SNI分流已配置(不必再次配置)。 +//4、修改/home/webdav的目录权限为0777,以便客户端具有写入及删除文件权限。 +//5、authentication中密码必须使用哈希密码,可用caddy hash-password --plaintext 命令把普通密码转化为哈希密码并输出。例如:/usr/bin/caddy hash-password --plaintext password diff --git a/Client Configuration/README.md b/Client Configuration/README.md new file mode 100644 index 00000000000..99d10e6c942 --- /dev/null +++ b/Client Configuration/README.md @@ -0,0 +1,11 @@ +介绍: + +本目录中各个文件为原版配置客户端的配置示例,对应服务端的各个应用示例。 + +注意: + +1、SS 为 shadowsocks 简写。 + +2、文件名称仅便于区分,使用时删除前边多余部分保留 config.json 即可。 + +3、若 PC 使用原版配置客户端,浏览器推荐使用 SwitchyOmega 插件来连接客户端的 SOCKS 或 HTTP 代理服务器。 diff --git a/Client Configuration/SS_v2ray-plugin_tls_config.json b/Client Configuration/SS_v2ray-plugin_tls_config.json new file mode 100644 index 00000000000..4b87c80d6a4 --- /dev/null +++ b/Client Configuration/SS_v2ray-plugin_tls_config.json @@ -0,0 +1,16 @@ +//客户端shadowsocks(SS)加xray-plugin或v2ray-plugin插件的WebSocket应用,其配置如下: +server address 'xx.yy' //修改为服务端配置的对应域名 +server port '443' //服务端配置的端口 +server password 'diy443' //修改为服务端配置的对应密码 +server method 'chacha20-poly1305' //修改为服务端配置的对应加密协议 +server plugin 'xray-plugin' //启用xray-plugin插件或v2ray-plugin插件 +server plugin_opts 'tls;host=xx.yy;path=/SS1v2ray;mux=4' //host修改为服务端配置的对应域名,path修改为服务端配置的对应path。 + + +//客户端shadowsocks(SS)加xray-plugin或v2ray-plugin插件的gRPC应用,其配置如下: +server address 'xx.yy' //修改为服务端配置的对应域名 +server port '443' //服务端配置的端口 +server password 'diy443' //修改为服务端配置的对应密码 +server method 'chacha20-poly1305' //修改为服务端配置的对应加密协议 +server plugin 'xray-plugin' //启用xray-plugin插件或v2ray-plugin插件 +server plugin_opts 'tls;mode=grpc;host=xx.yy;serviceName=scdngrpc' //host修改为服务端配置的对应域名,serviceName修改为服务端配置的对应serviceName。 diff --git a/Client Configuration/hysteria_config.json b/Client Configuration/hysteria_config.json new file mode 100644 index 00000000000..a20a1e655ef --- /dev/null +++ b/Client Configuration/hysteria_config.json @@ -0,0 +1,17 @@ +{ + "server": "xx.yy:2083", //修改为服务器端配置的域名及端口 + "protocol": "udp", //修改为服务器端配置的传输协议 + "acl": "route_list.acl", //修改为自己的ACL文件(选配)。若无此文件,那么必须删除此条参数。 + "obfs": "obfs2083", //修改为服务器端配置的混淆密码 + "auth": "[BASE64]", //修改为服务器端配置的Base64验证密钥(选配)。若服务器端无此部分配置,那么必须删除此条参数。 + "auth_str": "diy2083", //修改为服务器端配置的字符串验证密钥(选配,和上面的选项二选一。)。若服务器端无此部分配置,那么必须删除此条参数。 + "alpn": "h3", //修改为服务器端配置的alpn标签(选配)。若服务器端无此部分配置,那么必须删除此条参数。 + "up_mbps": 10, + "down_mbps": 50, + "socks5": { + "listen": "127.0.0.1:1080" + }, + "http": { + "listen": "127.0.0.1:8080" + } +} diff --git a/Client Configuration/naiveproxy_https_config.json b/Client Configuration/naiveproxy_https_config.json new file mode 100644 index 00000000000..4b3057411c8 --- /dev/null +++ b/Client Configuration/naiveproxy_https_config.json @@ -0,0 +1,5 @@ +{ + "listen": "socks://127.0.0.1:1080", + "proxy": "https://user:pass@xx.yy", //user修改为服务端配置的用户,pass修改为服务端配置的密码,xx.yy修改为服务端配置的对应域名。 + "log": "" +} diff --git a/Client Configuration/naiveproxy_quic_config.json b/Client Configuration/naiveproxy_quic_config.json new file mode 100644 index 00000000000..769fb75e902 --- /dev/null +++ b/Client Configuration/naiveproxy_quic_config.json @@ -0,0 +1,5 @@ +{ + "listen": "socks://127.0.0.1:1080", + "proxy": "quic://user:pass@xx.yy", //user修改为服务端配置的用户,pass修改为服务端配置的密码,xx.yy修改为服务端配置的对应域名。 + "log": "" +} diff --git a/Client Configuration/naiveproxy_sing-box/README.md b/Client Configuration/naiveproxy_sing-box/README.md new file mode 100644 index 00000000000..ab0f60f98f2 --- /dev/null +++ b/Client Configuration/naiveproxy_sing-box/README.md @@ -0,0 +1,11 @@ +**介绍:** + +本目录中配置文件利用 [sing-box](https://github.com/SagerNet/sing-box) 路由分流 + [naiveproxy](https://github.com/klzgrad/naiveproxy) 实现科学上网。 + +使用时需要同时启动 sing-box 与 naiveproxy。 + +相比 v2ray + naiveproxy,本配置有如下优势 +* sing-box 带来更高的性能和更低的占用; +* 原生支持 [UDP over TCP](https://github.com/SagerNet/UoT)【服务端需使用 [SagerNet/forwardproxy](https://github.com/SagerNet/forwardproxy) 插件】,使 naiveproxy 可以传输 UDP 数据报; +* [自动配置系统代理](https://sing-box.sagernet.org/configuration/inbound/mixed/#set_system_proxy)(支持 Linux, Android, Windows, macOS),同端口开启 HTTP/SOCKS 入站。 + \ No newline at end of file diff --git a/Client Configuration/naiveproxy_sing-box/naiveproxy_config.json b/Client Configuration/naiveproxy_sing-box/naiveproxy_config.json new file mode 100644 index 00000000000..ae905d1f475 --- /dev/null +++ b/Client Configuration/naiveproxy_sing-box/naiveproxy_config.json @@ -0,0 +1,5 @@ +{ + "listen": "socks://127.0.0.1:52000", + "proxy": "://:@[:]", + "log": "/tmp/naive.log" + } diff --git a/Client Configuration/naiveproxy_sing-box/sing-box_routing.json b/Client Configuration/naiveproxy_sing-box/sing-box_routing.json new file mode 100644 index 00000000000..61493f5515a --- /dev/null +++ b/Client Configuration/naiveproxy_sing-box/sing-box_routing.json @@ -0,0 +1,79 @@ +{ + "log": { + "disabled": false, + "level": "error", + "output": "/tmp/sing-box.log", + "timestamp": true + }, + "dns": { + "servers": [ + { + "tag": "cloudflare", + "address": "tls://1.0.0.1:863", + "address_strategy": "prefer_ipv4", + "detour": "proxy_out" + }, + { + "tag": "alidns", + "address": "223.5.5.5", + "address_strategy": "prefer_ipv4", + "detour": "direct_out" + } + ], + "rules": [ + { + "geosite":[ + "cn" + ], + "server": "alidns" + } + ] + }, + "inbounds": [ + { + "type": "mixed", + "tag": "mixed-in", + "listen": "::", + "listen_port": 2080, + "sniff": true, + "set_system_proxy": true + } + ], + "route": { + "rules": [ + { + "geosite": [ + "cn" + ], + "geoip": [ + "cn", + "private" + ], + "outbound": "direct_out" + }, + { + "geosite": [ + "category-ads-all" + ], + "outbound": "block" + } + ] + }, + "outbounds": [ + { + "tag": "proxy_out", + "type": "socks", + "server": "127.0.0.1", + "server_port": 52000, + "udp_over_tcp": true + }, + { + "type": "direct", + "tag": "direct_out" + }, + { + "type": "block", + "tag": "block" + } + ] +} diff --git a/Client Configuration/naiveproxy_v2ray/README.md b/Client Configuration/naiveproxy_v2ray/README.md new file mode 100644 index 00000000000..07ffa5f33d9 --- /dev/null +++ b/Client Configuration/naiveproxy_v2ray/README.md @@ -0,0 +1,10 @@ +**介绍:** + +本目录中配置文件利用 v2ray 路由分流 + naiveproxy 实现科学上网。 + +使用时需要同时启动 v2ray 与 naiveproxy,主机设置代理服务器为 socks5://127.0.0.1:1080 即可。 + +**参考文献:** +[naiveproxy](https://github.com/klzgrad/naiveproxy);klzgrad +[V2Fly 配置文档::Routing 路由](https://www.v2fly.org/config/routing.html);V2Fly community +[Project X::小小白白话文::【第 8 章】Xray 客户端篇](https://xtls.github.io/Xray-docs-next/document/level-0/ch08-xray-clients.html);Project X Community diff --git a/Client Configuration/naiveproxy_v2ray/naiveproxy_config.json b/Client Configuration/naiveproxy_v2ray/naiveproxy_config.json new file mode 100644 index 00000000000..ae905d1f475 --- /dev/null +++ b/Client Configuration/naiveproxy_v2ray/naiveproxy_config.json @@ -0,0 +1,5 @@ +{ + "listen": "socks://127.0.0.1:52000", + "proxy": "://:@[:]", + "log": "/tmp/naive.log" + } diff --git a/Client Configuration/naiveproxy_v2ray/v2ray_routing.json b/Client Configuration/naiveproxy_v2ray/v2ray_routing.json new file mode 100644 index 00000000000..f90e6b89528 --- /dev/null +++ b/Client Configuration/naiveproxy_v2ray/v2ray_routing.json @@ -0,0 +1,103 @@ +{ + "log": { + "loglevel": "error", + "error": "/tmp/v2_err.log" + }, + "dns": { + "servers": [ + { + "address": "tcp://1.1.1.1:53", + "domains": ["geosite:geolocation-!cn"] + }, + { + "address": "114.114.114.114", + "domains": ["geosite:cn"], + "expectIPs": ["geoip:cn"] + }, + { + "address": "223.5.5.5", + "domains": ["geosite:cn"] + }, + "localhost" + ] + }, + "inbounds": [ + { + "port": 1080, + "listen": "127.0.0.1", + "tag": "socks-inbound", + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true + }, + "sniffing": { + "enabled": true, + "destOverride": ["http", "tls"] + } + } + ], + "routing": { + "domainStrategy": "IPIfNonMatch", + "domainMatcher": "mph", + "rules": [ + { + "type": "field", + "domain": ["geosite:category-ads-all"], + "outboundTag": "blocked" + }, + { + "type": "field", + "domain": ["geosite:cn"], + "outboundTag": "direct" + }, + { + "type": "field", + "ip": ["geoip:cn", "geoip:private"], + "outboundTag": "direct" + }, + { + "type": "field", + "domain": ["geosite:geolocation-!cn"], + "outboundTag": "proxy" + }, + { + "type": "field", + "ip": ["114.114.114.114"], + "outboundTag": "direct" + }, + { + "type": "field", + "ip": ["1.1.1.1"], + "outboundTag": "proxy" + } + ] + }, + "outbounds": [ + { + "protocol": "socks", + "settings": { + "servers": [ + { + "address": "127.0.0.1", + "port": 52000 + } + ] + }, + "tag": "proxy" + }, + { + "protocol": "blackhole", + "settings": { + "response": { + "type": "http" + } + }, + "tag": "blocked" + }, + { + "protocol": "freedom", + "tag": "direct" + } + ] +} diff --git a/Client Configuration/v2ray_SS_grpc_tls_config.json b/Client Configuration/v2ray_SS_grpc_tls_config.json new file mode 100644 index 00000000000..00b6eb95744 --- /dev/null +++ b/Client Configuration/v2ray_SS_grpc_tls_config.json @@ -0,0 +1,67 @@ +{ + "log": {}, + "inbounds": [ + { + "port": "1080", + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true + } + }, + { + "port": "1081", + "protocol": "http", + "settings": {} + } + ], + "outbounds": [ + { + "protocol": "shadowsocks", + "settings": { + "servers": [ + { + "address": "xx.yy", //修改为服务端配置的对应域名 + "port": 443, //服务端配置的端口 + "method": "chacha20-poly1305", //修改为服务端配置的对应加密协议 + "password": "diy443", //修改为服务端配置的对应密码 + "ota": false + } + ] + }, + "streamSettings": { + "security": "tls", + "tlsSettings": { + "fingerprint": "chrome" //模拟TLS指纹,可任一chrome、firefox、safari、ios、edge、qq、random、randomized选项配置。 + }, //仅Xray支持此应用,否则必须删除此部分配置。 + "network": "grpc", + "grpcSettings": { + "serviceName": "sdngrpc" //修改为服务端配置的对应gRPC服务名称 + } + } + }, + { + "tag": "direct", //如果要使用路由,这个tag是一定要有的,在这里direct就是freedom的一个标号。 + "protocol": "freedom", + "settings": {} + } + ], + "routing": { + "domainStrategy": "IPOnDemand", + "rules": [ + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "domain": ["geosite:cn"] //中国大陆主流网站的域名 + }, + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "ip": [ + "geoip:cn", //中国大陆的IP + "geoip:private" //私有地址IP,如路由器等。 + ] + } + ] + } +} diff --git a/Client Configuration/v2ray_trojan_grpc_tls_config.json b/Client Configuration/v2ray_trojan_grpc_tls_config.json new file mode 100644 index 00000000000..a9bcc205177 --- /dev/null +++ b/Client Configuration/v2ray_trojan_grpc_tls_config.json @@ -0,0 +1,65 @@ +{ + "log": {}, + "inbounds": [ + { + "port": "1080", + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true + } + }, + { + "port": "1081", + "protocol": "http", + "settings": {} + } + ], + "outbounds": [ + { + "protocol": "trojan", + "settings": { + "servers": [ + { + "address": "xx.yy", //修改为服务端配置的对应域名 + "port": 443, //服务端配置的端口 + "password": "diy443", //修改为服务端配置的对应密码 + } + ] + }, + "streamSettings": { + "security": "tls", + "tlsSettings": { + "fingerprint": "chrome" //模拟TLS指纹,可任一chrome、firefox、safari、ios、edge、qq、random、randomized选项配置。 + }, //仅Xray支持此应用,否则必须删除此部分配置。 + "network": "grpc", + "grpcSettings": { + "serviceName": "tdngrpc" //修改为服务端配置的对应gRPC服务名称 + } + } + }, + { + "tag": "direct", //如果要使用路由,这个tag是一定要有的,在这里direct就是freedom的一个标号。 + "protocol": "freedom", + "settings": {} + } + ], + "routing": { + "domainStrategy": "IPOnDemand", + "rules": [ + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "domain": ["geosite:cn"] //中国大陆主流网站的域名 + }, + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "ip": [ + "geoip:cn", //中国大陆的IP + "geoip:private" //私有地址IP,如路由器等。 + ] + } + ] + } +} diff --git a/Client Configuration/v2ray_trojan_h2_tls_config.json b/Client Configuration/v2ray_trojan_h2_tls_config.json new file mode 100644 index 00000000000..e047da2794b --- /dev/null +++ b/Client Configuration/v2ray_trojan_h2_tls_config.json @@ -0,0 +1,65 @@ +{ + "log": {}, + "inbounds": [ + { + "port": "1080", + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true + } + }, + { + "port": "1081", + "protocol": "http", + "settings": {} + } + ], + "outbounds": [ + { + "protocol": "trojan", + "settings": { + "servers": [ + { + "address": "xx.yy", //修改为服务端配置的对应域名 + "port": 443, //服务端配置的端口 + "password": "diy443", //修改为服务端配置的对应密码 + } + ] + }, + "streamSettings": { + "security": "tls", + "tlsSettings": { + "fingerprint": "chrome" //模拟TLS指纹,可任一chrome、firefox、safari、ios、edge、qq、random、randomized选项配置。 + }, //仅Xray支持此应用,否则必须删除此部分配置。 + "network": "h2", + "httpSettings": { + "path": "/teuW56Es" //修改为服务端配置的对应path + } + } + }, + { + "tag": "direct", //如果要使用路由,这个tag是一定要有的,在这里direct就是freedom的一个标号。 + "protocol": "freedom", + "settings": {} + } + ], + "routing": { + "domainStrategy": "IPOnDemand", + "rules": [ + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "domain": ["geosite:cn"] //中国大陆主流网站的域名 + }, + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "ip": [ + "geoip:cn", //中国大陆的IP + "geoip:private" //私有地址IP,如路由器等。 + ] + } + ] + } +} diff --git a/Client Configuration/v2ray_trojan_ws_tls_config.json b/Client Configuration/v2ray_trojan_ws_tls_config.json new file mode 100644 index 00000000000..adee8d0122b --- /dev/null +++ b/Client Configuration/v2ray_trojan_ws_tls_config.json @@ -0,0 +1,69 @@ +{ + "log": {}, + "inbounds": [ + { + "port": "1080", + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true + } + }, + { + "port": "1081", + "protocol": "http", + "settings": {} + } + ], + "outbounds": [ + { + "protocol": "trojan", + "settings": { + "servers": [ + { + "address": "xx.yy", //修改为服务端配置的对应域名 + "port": 443, //服务端配置的端口 + "password": "diy443", //修改为服务端配置的对应密码 + } + ] + }, + "streamSettings": { + "security": "tls", + "tlsSettings": { + "fingerprint": "chrome" //模拟TLS指纹,可任一chrome、firefox、safari、ios、edge、qq、random、randomized选项配置。 + }, //仅Xray支持此应用,否则必须删除此部分配置。 + "network": "ws", + "wsSettings": { + "path": "/9ALdGZ9k" //修改为服务端配置的对应path。大于Xray-core v1.4.0版本,path后加上?ed=2048即可开启WebSocket 0-RTT。 + } + }, + "mux": { + "enabled": true, //多路复用开关,默认启用。因兼容性,多路复用仅与原版服务端连接才可启用,否则必须关闭。 + "concurrency": 4 //此数据根据网络情况调整。表示4条传输进程复合一个链路发出。 + } + }, + { + "tag": "direct", //如果要使用路由,这个tag是一定要有的,在这里direct就是freedom的一个标号。 + "protocol": "freedom", + "settings": {} + } + ], + "routing": { + "domainStrategy": "IPOnDemand", + "rules": [ + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "domain": ["geosite:cn"] //中国大陆主流网站的域名 + }, + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "ip": [ + "geoip:cn", //中国大陆的IP + "geoip:private" //私有地址IP,如路由器等。 + ] + } + ] + } +} diff --git a/Client Configuration/v2ray_vless_grpc_tls_config.json b/Client Configuration/v2ray_vless_grpc_tls_config.json new file mode 100644 index 00000000000..0bd6944cb9e --- /dev/null +++ b/Client Configuration/v2ray_vless_grpc_tls_config.json @@ -0,0 +1,70 @@ +{ + "log": {}, + "inbounds": [ + { + "port": "1080", + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true + } + }, + { + "port": "1081", + "protocol": "http", + "settings": {} + } + ], + "outbounds": [ + { + "protocol": "vless", + "settings": { + "vnext": [ + { + "address": "xx.yy", //修改为服务端配置的对应域名 + "port": 443, //服务端配置的端口 + "users": [ + { + "id": "058e0bf3-dd56-11e9-aa37-5600024c1d6a", //修改为服务端配置的对应UUID + "encryption": "none" + } + ] + } + ] + }, + "streamSettings": { + "security": "tls", + "tlsSettings": { + "fingerprint": "chrome" //模拟TLS指纹,可任一chrome、firefox、safari、ios、edge、qq、random、randomized选项配置。 + }, //仅Xray支持此应用,否则必须删除此部分配置。 + "network": "grpc", + "grpcSettings": { + "serviceName": "cdngrpc" //修改为服务端配置的对应gRPC服务名称 + } + } + }, + { + "tag": "direct", //如果要使用路由,这个tag是一定要有的,在这里direct就是freedom的一个标号。 + "protocol": "freedom", + "settings": {} + } + ], + "routing": { + "domainStrategy": "IPOnDemand", + "rules": [ + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "domain": ["geosite:cn"] //中国大陆主流网站的域名 + }, + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "ip": [ + "geoip:cn", //中国大陆的IP + "geoip:private" //私有地址IP,如路由器等。 + ] + } + ] + } +} diff --git a/Client Configuration/v2ray_vless_h2_tls_config.json b/Client Configuration/v2ray_vless_h2_tls_config.json new file mode 100644 index 00000000000..c8a1dace362 --- /dev/null +++ b/Client Configuration/v2ray_vless_h2_tls_config.json @@ -0,0 +1,70 @@ +{ + "log": {}, + "inbounds": [ + { + "port": "1080", + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true + } + }, + { + "port": "1081", + "protocol": "http", + "settings": {} + } + ], + "outbounds": [ + { + "protocol": "vless", + "settings": { + "vnext": [ + { + "address": "xx.yy", //修改为服务端配置的对应域名 + "port": 443, //服务端配置的端口 + "users": [ + { + "id": "a3d238a4-b777-11ea-90d6-42010a8c000a", //修改为服务端配置的对应UUID + "encryption": "none" + } + ] + } + ] + }, + "streamSettings": { + "security": "tls", + "tlsSettings": { + "fingerprint": "chrome" //模拟TLS指纹,可任一chrome、firefox、safari、ios、edge、qq、random、randomized选项配置。 + }, //仅Xray支持此应用,否则必须删除此部分配置。 + "network": "h2", + "httpSettings": { + "path": "/nSBv5RjE" //修改为服务端配置的对应path + } + } + }, + { + "tag": "direct", //如果要使用路由,这个tag是一定要有的,在这里direct就是freedom的一个标号。 + "protocol": "freedom", + "settings": {} + } + ], + "routing": { + "domainStrategy": "IPOnDemand", + "rules": [ + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "domain": ["geosite:cn"] //中国大陆主流网站的域名 + }, + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "ip": [ + "geoip:cn", //中国大陆的IP + "geoip:private" //私有地址IP,如路由器等。 + ] + } + ] + } +} diff --git a/Client Configuration/v2ray_vless_kcp_config.json b/Client Configuration/v2ray_vless_kcp_config.json new file mode 100644 index 00000000000..c9f45df49b0 --- /dev/null +++ b/Client Configuration/v2ray_vless_kcp_config.json @@ -0,0 +1,72 @@ +{ + "log": {}, + "inbounds": [ + { + "port": "1080", + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true + } + }, + { + "port": "1081", + "protocol": "http", + "settings": {} + } + ], + "outbounds": [ + { + "protocol": "vless", + "settings": { + "vnext": [ + { + "address": "xx.yy", //修改为服务端配置的对应域名或ip + "port": 2053, //修改为服务端配置的对应端口 + "users": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为服务端配置的对应UUID + "encryption":"none" + } + ] + } + ] + }, + "streamSettings": { + "security": "none", + "network": "kcp", + "kcpSettings": { + "congestion": true, + "seed": "60VoqhfjP79nBQyU" //修改为服务端配置的对应seed密码 + } + }, + "mux": { + "enabled": true, //建议开启 + "concurrency": 4 //此数据根据网络情况调整。表示4条传输进程复合一个链路发出。 + } + }, + { + "tag": "direct", //如果要使用路由,这个tag是一定要有的,在这里direct就是freedom的一个标号。 + "protocol": "freedom", + "settings": {} + } + ], + "routing": { + "domainStrategy": "IPOnDemand", + "rules": [ + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "domain": ["geosite:cn"] //中国大陆主流网站的域名 + }, + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "ip": [ + "geoip:cn", //中国大陆的IP + "geoip:private" //私有地址IP,如路由器等。 + ] + } + ] + } +} diff --git a/Client Configuration/v2ray_vless_ws_tls_config.json b/Client Configuration/v2ray_vless_ws_tls_config.json new file mode 100644 index 00000000000..6a791d78ff2 --- /dev/null +++ b/Client Configuration/v2ray_vless_ws_tls_config.json @@ -0,0 +1,74 @@ +{ + "log": {}, + "inbounds": [ + { + "port": "1080", + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true + } + }, + { + "port": "1081", + "protocol": "http", + "settings": {} + } + ], + "outbounds": [ + { + "protocol": "vless", + "settings": { + "vnext": [ + { + "address": "xx.yy", //修改为服务端配置的对应域名 + "port": 443, //服务端配置的端口 + "users": [ + { + "id": "a3d238a4-b777-11ea-90d6-42010a8c000a", //修改为服务端配置的对应UUID + "encryption": "none" + } + ] + } + ] + }, + "streamSettings": { + "security": "tls", + "tlsSettings": { + "fingerprint": "chrome" //模拟TLS指纹,可任一chrome、firefox、safari、ios、edge、qq、random、randomized选项配置。 + }, //仅Xray支持此应用,否则必须删除此部分配置。 + "network": "ws", + "wsSettings": { + "path": "/5hBv56Es" //修改为服务端配置的对应path。大于Xray-core v1.4.0版本,path后加上?ed=2048即可开启WebSocket 0-RTT。 + } + }, + "mux": { + "enabled": true, //ws类传输方式,建议开启。 + "concurrency": 4 //此数据根据网络情况调整。表示4条传输进程复合一个链路发出。 + } + }, + { + "tag": "direct", //如果要使用路由,这个tag是一定要有的,在这里direct就是freedom的一个标号。 + "protocol": "freedom", + "settings": {} + } + ], + "routing": { + "domainStrategy": "IPOnDemand", + "rules": [ + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "domain": ["geosite:cn"] //中国大陆主流网站的域名 + }, + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "ip": [ + "geoip:cn", //中国大陆的IP + "geoip:private" //私有地址IP,如路由器等。 + ] + } + ] + } +} diff --git a/Client Configuration/v2ray_vmess_grpc_tls_config.json b/Client Configuration/v2ray_vmess_grpc_tls_config.json new file mode 100644 index 00000000000..e400804f541 --- /dev/null +++ b/Client Configuration/v2ray_vmess_grpc_tls_config.json @@ -0,0 +1,70 @@ +{ + "log": {}, + "inbounds": [ + { + "port": "1080", + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true + } + }, + { + "port": "1081", + "protocol": "http", + "settings": {} + } + ], + "outbounds": [ + { + "protocol": "vmess", + "settings": { + "vnext": [ + { + "address": "xx.yy", //修改为服务端配置的对应域名 + "port": 443, //服务端配置的端口 + "users": [ + { + "id": "058e0bf3-dd56-11e9-aa37-5600024c1d6a", //修改为服务端配置的对应UUID + "security": "auto" + } + ] + } + ] + }, + "streamSettings": { + "security": "tls", + "tlsSettings": { + "fingerprint": "chrome" //模拟TLS指纹,可任一chrome、firefox、safari、ios、edge、qq、random、randomized选项配置。 + }, //仅Xray支持此应用,否则必须删除此部分配置。 + "network": "grpc", + "grpcSettings": { + "serviceName": "cdngrpc" //修改为服务端配置的对应gRPC服务名称 + } + } + }, + { + "tag": "direct", //如果要使用路由,这个tag是一定要有的,在这里direct就是freedom的一个标号。 + "protocol": "freedom", + "settings": {} + } + ], + "routing": { + "domainStrategy": "IPOnDemand", + "rules": [ + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "domain": ["geosite:cn"] //中国大陆主流网站的域名 + }, + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "ip": [ + "geoip:cn", //中国大陆的IP + "geoip:private" //私有地址IP,如路由器等。 + ] + } + ] + } +} diff --git a/Client Configuration/v2ray_vmess_kcp_config.json b/Client Configuration/v2ray_vmess_kcp_config.json new file mode 100644 index 00000000000..fbbd00fabd8 --- /dev/null +++ b/Client Configuration/v2ray_vmess_kcp_config.json @@ -0,0 +1,72 @@ +{ + "log": {}, + "inbounds": [ + { + "port": "1080", + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true + } + }, + { + "port": "1081", + "protocol": "http", + "settings": {} + } + ], + "outbounds": [ + { + "protocol": "vmess", + "settings": { + "vnext": [ + { + "address": "xx.yy", //修改为服务端配置的对应域名或ip + "port": 2053, //修改为服务端配置的对应端口 + "users": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为服务端配置的对应UUID + "security": "auto" + } + ] + } + ] + }, + "streamSettings": { + "security": "none", + "network": "kcp", + "kcpSettings": { + "congestion": true, + "seed": "60VoqhfjP79nBQyU" //修改为服务端配置的对应seed密码 + } + }, + "mux": { + "enabled": true, //建议开启 + "concurrency": 4 //此数据根据网络情况调整。表示4条传输进程复合一个链路发出。 + } + }, + { + "tag": "direct", //如果要使用路由,这个tag是一定要有的,在这里direct就是freedom的一个标号。 + "protocol": "freedom", + "settings": {} + } + ], + "routing": { + "domainStrategy": "IPOnDemand", + "rules": [ + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "domain": ["geosite:cn"] //中国大陆主流网站的域名 + }, + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "ip": [ + "geoip:cn", //中国大陆的IP + "geoip:private" //私有地址IP,如路由器等。 + ] + } + ] + } +} diff --git a/Client Configuration/v2ray_vmess_ws_tls_config.json b/Client Configuration/v2ray_vmess_ws_tls_config.json new file mode 100644 index 00000000000..7acd9d7f279 --- /dev/null +++ b/Client Configuration/v2ray_vmess_ws_tls_config.json @@ -0,0 +1,74 @@ +{ + "log": {}, + "inbounds": [ + { + "port": "1080", + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true + } + }, + { + "port": "1081", + "protocol": "http", + "settings": {} + } + ], + "outbounds": [ + { + "protocol": "vmess", + "settings": { + "vnext": [ + { + "address": "xx.yy", //修改为服务端配置的对应域名 + "port": 443, //服务端配置的端口 + "users": [ + { + "id": "a343b796-66eb-11ea-a4e2-42010aaa0019", //修改为服务端配置的对应UUID + "security": "auto" + } + ] + } + ] + }, + "streamSettings": { + "security": "tls", + "tlsSettings": { + "fingerprint": "chrome" //模拟TLS指纹,可任一chrome、firefox、safari、ios、edge、qq、random、randomized选项配置。 + }, //仅Xray支持此应用,否则必须删除此部分配置。 + "network": "ws", + "wsSettings": { + "path": "/5hBv56Es" //修改为服务端配置的对应path。大于Xray-core v1.4.0版本,path后加上?ed=2048即可开启WebSocket 0-RTT。 + } + }, + "mux": { + "enabled": true, //ws类传输方式,建议开启。 + "concurrency": 4 //此数据根据网络情况调整。表示4条传输进程复合一个链路发出。 + } + }, + { + "tag": "direct", //如果要使用路由,这个tag是一定要有的,在这里direct就是freedom的一个标号。 + "protocol": "freedom", + "settings": {} + } + ], + "routing": { + "domainStrategy": "IPOnDemand", + "rules": [ + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "domain": ["geosite:cn"] //中国大陆主流网站的域名 + }, + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "ip": [ + "geoip:cn", //中国大陆的IP + "geoip:private" //私有地址IP,如路由器等。 + ] + } + ] + } +} diff --git a/Client Configuration/xray_SS_grpc_reality_config.json b/Client Configuration/xray_SS_grpc_reality_config.json new file mode 100644 index 00000000000..2799e6ba2b2 --- /dev/null +++ b/Client Configuration/xray_SS_grpc_reality_config.json @@ -0,0 +1,69 @@ +{ + "log": {}, + "inbounds": [ + { + "port": "1080", + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true + } + }, + { + "port": "1081", + "protocol": "http", + "settings": {} + } + ], + "outbounds": [ + { + "protocol": "shadowsocks", + "settings": { + "servers": [ + { + "address": "2.2.2.2", //修改为服务端对应IP + "port": 443, //服务端配置的端口 + "method": "chacha20-poly1305", //修改为服务端配置的对应加密协议 + "password": "diy443", //修改为服务端配置的对应密码 + "ota": false + } + ] + }, + "streamSettings": { + "network": "grpc", + "security": "reality", + "realitySettings": { + "show": false, + "fingerprint": "chrome", //模拟TLS指纹,可任一chrome、firefox、safari、ios、edge、qq、random、randomized选项配置。 + "serverName": "xx.yy", //修改为服务端配置的对应域名 + "publicKey": "nUal5RIspF9LFWNAvKhXQCD6m0UokNR9e4IP7CFKphQ", //修改为服务端私钥对应的公钥 + "shortId": "", //修改为服务端shortIds配置之一 + "spiderX": "" //选填,爬虫初始路径与参数,建议每个客户端不同。 + } + } + }, + { + "tag": "direct", //如果要使用路由,这个tag是一定要有的,在这里direct就是freedom的一个标号。 + "protocol": "freedom", + "settings": {} + } + ], + "routing": { + "domainStrategy": "IPOnDemand", + "rules": [ + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "domain": ["geosite:cn"] //中国大陆主流网站的域名 + }, + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "ip": [ + "geoip:cn", //中国大陆的IP + "geoip:private" //私有地址IP,如路由器等。 + ] + } + ] + } +} diff --git a/Client Configuration/xray_trojan_tcp_tls_config.json b/Client Configuration/xray_trojan_tcp_tls_config.json new file mode 100644 index 00000000000..2abc797d7cd --- /dev/null +++ b/Client Configuration/xray_trojan_tcp_tls_config.json @@ -0,0 +1,63 @@ +{ + "log": {}, + "inbounds": [ + { + "port": "1080", + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true + } + }, + { + "port": "1081", + "protocol": "http", + "settings": {} + } + ], + "outbounds": [ + { + "protocol": "trojan", + "settings": { + "servers": [ + { + "address": "xx.yy", //修改为服务端配置的对应域名 + "port": 443, //服务端配置的端口 + "password": "diy443" //修改为服务端配置的对应密码 + } + ] + }, + "streamSettings": { + "security": "tls", + "tlsSettings": { + "fingerprint": "chrome" //模拟TLS指纹,可任一chrome、firefox、safari、ios、edge、qq、random、randomized选项配置。 + }, + "network": "tcp", + "tcpSettings": {} + } + }, + { + "tag": "direct", //如果要使用路由,这个tag是一定要有的,在这里direct就是freedom的一个标号。 + "protocol": "freedom", + "settings": {} + } + ], + "routing": { + "domainStrategy": "IPOnDemand", + "rules": [ + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "domain": ["geosite:cn"] //中国大陆主流网站的域名 + }, + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "ip": [ + "geoip:cn", //中国大陆的IP + "geoip:private" //私有地址IP,如路由器等。 + ] + } + ] + } +} diff --git a/Client Configuration/xray_vless_h2_reality_config.json b/Client Configuration/xray_vless_h2_reality_config.json new file mode 100644 index 00000000000..7db7aae4f93 --- /dev/null +++ b/Client Configuration/xray_vless_h2_reality_config.json @@ -0,0 +1,72 @@ +{ + "log": {}, + "inbounds": [ + { + "port": "1080", + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true + } + }, + { + "port": "1081", + "protocol": "http", + "settings": {} + } + ], + "outbounds": [ + { + "protocol": "vless", + "settings": { + "vnext": [ + { + "address": "2.2.2.2", //修改为服务端对应IP + "port": 443, //服务端配置的端口 + "users": [ + { + "id": "a3d238a4-b777-11ea-90d6-42010a8c000a", //修改为服务端配置的对应UUID + "encryption": "none" + } + ] + } + ] + }, + "streamSettings": { + "network": "h2", + "security": "reality", + "realitySettings": { + "show": false, + "fingerprint": "chrome", //模拟TLS指纹,可任一chrome、firefox、safari、ios、edge、qq、random、randomized选项配置。 + "serverName": "xx.yy", //修改为服务端配置的对应域名 + "publicKey": "nUal5RIspF9LFWNAvKhXQCD6m0UokNR9e4IP7CFKphQ", //修改为服务端私钥对应的公钥 + "shortId": "", //修改为服务端shortIds配置之一 + "spiderX": "" //选填,爬虫初始路径与参数,建议每个客户端不同。 + } + } + }, + { + "tag": "direct", //如果要使用路由,这个tag是一定要有的,在这里direct就是freedom的一个标号。 + "protocol": "freedom", + "settings": {} + } + ], + "routing": { + "domainStrategy": "IPOnDemand", + "rules": [ + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "domain": ["geosite:cn"] //中国大陆主流网站的域名 + }, + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "ip": [ + "geoip:cn", //中国大陆的IP + "geoip:private" //私有地址IP,如路由器等。 + ] + } + ] + } +} diff --git a/Client Configuration/xray_vless_vision_reality_config.json b/Client Configuration/xray_vless_vision_reality_config.json new file mode 100644 index 00000000000..c8170b7cbe4 --- /dev/null +++ b/Client Configuration/xray_vless_vision_reality_config.json @@ -0,0 +1,73 @@ +{ + "log": {}, + "inbounds": [ + { + "port": "1080", + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true + } + }, + { + "port": "1081", + "protocol": "http", + "settings": {} + } + ], + "outbounds": [ + { + "protocol": "vless", + "settings": { + "vnext": [ + { + "address": "2.2.2.2", //修改为服务端对应IP + "port": 443, //服务端配置的端口 + "users": [ + { + "id": "7326a426-d601-11ea-b574-560002e9f264", //修改为服务端配置的对应UUID + "flow": "xtls-rprx-vision", + "encryption": "none" + } + ] + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "reality", + "realitySettings": { + "show": false, + "fingerprint": "chrome", //模拟TLS指纹,可任一chrome、firefox、safari、ios、edge、qq、random、randomized选项配置。 + "serverName": "xx.yy", //修改为服务端配置的对应域名 + "publicKey": "nUal5RIspF9LFWNAvKhXQCD6m0UokNR9e4IP7CFKphQ", //修改为服务端私钥对应的公钥 + "shortId": "", //修改为服务端shortIds配置之一 + "spiderX": "" //选填,爬虫初始路径与参数,建议每个客户端不同。 + } + } + }, + { + "tag": "direct", //如果要使用路由,这个tag是一定要有的,在这里direct就是freedom的一个标号。 + "protocol": "freedom", + "settings": {} + } + ], + "routing": { + "domainStrategy": "IPOnDemand", + "rules": [ + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "domain": ["geosite:cn"] //中国大陆主流网站的域名 + }, + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "ip": [ + "geoip:cn", //中国大陆的IP + "geoip:private" //私有地址IP,如路由器等。 + ] + } + ] + } +} diff --git a/Client Configuration/xray_vless_vision_tls_config.json b/Client Configuration/xray_vless_vision_tls_config.json new file mode 100644 index 00000000000..dc7e3c54ec1 --- /dev/null +++ b/Client Configuration/xray_vless_vision_tls_config.json @@ -0,0 +1,69 @@ +{ + "log": {}, + "inbounds": [ + { + "port": "1080", + "protocol": "socks", + "settings": { + "auth": "noauth", + "udp": true + } + }, + { + "port": "1081", + "protocol": "http", + "settings": {} + } + ], + "outbounds": [ + { + "protocol": "vless", + "settings": { + "vnext": [ + { + "address": "xx.yy", //修改为服务端配置的对应域名 + "port": 443, //服务端配置的端口 + "users": [ + { + "id": "7326a426-d601-11ea-b574-560002e9f264", //修改为服务端配置的对应UUID + "flow": "xtls-rprx-vision", + "encryption": "none" + } + ] + } + ] + }, + "streamSettings": { + "security": "tls", + "tlsSettings": { + "fingerprint": "chrome" //模拟TLS指纹,可任一chrome、firefox、safari、ios、edge、qq、random、randomized选项配置。 + }, + "network": "tcp", + "tcpSettings": {} + } + }, + { + "tag": "direct", //如果要使用路由,这个tag是一定要有的,在这里direct就是freedom的一个标号。 + "protocol": "freedom", + "settings": {} + } + ], + "routing": { + "domainStrategy": "IPOnDemand", + "rules": [ + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "domain": ["geosite:cn"] //中国大陆主流网站的域名 + }, + { + "type": "field", + "outboundTag": "direct", //与上tag对应 + "ip": [ + "geoip:cn", //中国大陆的IP + "geoip:private" //私有地址IP,如路由器等。 + ] + } + ] + } +} diff --git a/Hysteria/README.md b/Hysteria/README.md new file mode 100644 index 00000000000..d930af10b21 --- /dev/null +++ b/Hysteria/README.md @@ -0,0 +1,21 @@ +介绍: + +Hysteria 是一个功能丰富的、专为恶劣网络环境进行优化的网络工具(双边加速),基于修改版的 QUIC 协议,可实现 SOCKS5 代理 (TCP & UDP)、HTTP/HTTPS 代理、TCP/UDP 转发、TCP/UDP TPROXY 透明代理 (Linux)、TUN (Windows 下为 TAP) 应用。 + +注意: + +1、Hysteria(内置 ACME 客户端) 目前仅支持 HTTP-01 与 TLS-ALPN-01 验证方式申请与更新 TLS 证书,不支持 DNS-01 验证方式申请与更新 TLS 证书(即不支持申请通配符 TLS 证书)。对于 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书请分别确保 80 或 443 端口无其它应用占用。 + +2、acme_config.json 示例表示使用内置 ACME 客户端从 Let's Encrypt 为服务端自动申请与更新 TLS 证书(独自使用推荐),outside_config.json 示例表示使用外部 TLS 证书(已有科学上网应用再增加此应用推荐);两示例根据实际情况二选一即可。 + +3、Hysteria 使用外部 TLS 证书时不支持‘证书热更新’功能,即 Hysteria 不会自动识别 TLS 证书更新并重载 TLS 证书,可使用如下方法之一解决。 + +1)、Linux 类系统使用 Crontab 指令定时重启 Hysteria 来重载更新后的 TLS 证书,其它系统使用类似命令/工具来定时重启 Hysteria 来重载更新后的 TLS 证书。(通用办法) + +2)、若 TLS 证书由 Caddy(内置 ACME 客户端) 提供,可使用 caddy-events-exec 插件应用实现 TLS 证书自动更新后就执行重启 Hysteria 来重载更新后的 TLS 证书,详见 ‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。(Caddy 专属办法) + +3)、若 TLS 证书由 acme.sh 客户端提供,可使用 reloadcmd 参数实现 TLS 证书自动更新后就执行重启 Hysteria 来重载更新后的 TLS 证书,详见 acme.sh 客户端说明。(acme.sh 专属办法) + +4、若网络极差推荐部署,相比 V2Ray 或 Xray 的 mKCP 应用加速明显。 + +5、若要用 Hysteria 进行高速传输,请[增加系统 UDP 的接收和发送 buffer 大小](https://hysteria.network/zh/docs/optimizations/)。 diff --git a/Hysteria/acme_config.json b/Hysteria/acme_config.json new file mode 100644 index 00000000000..db6c4bd0d6d --- /dev/null +++ b/Hysteria/acme_config.json @@ -0,0 +1,20 @@ +{ + "listen": ":2083", //监听端口 + "protocol": "udp", //留空或"udp","wechat-video","faketcp" + "acme": { + "domains": [ + "xx.yy" //修改为自己的域名 + ], + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }, + "obfs": "obfs2083", //修改为自己的混淆密码 + "auth": { //验证配置(此部分选配)。客户端或服务端性能很垃圾,推荐不配置此部分参数。 + "mode": "password", //验证模式,目前支持"none","passwords","external"。普通用户不推荐使用external(外部验证接入)验证模式。 + "config": [ + "diy2083" //修改为自己的验证密钥,验证密钥可多组("password"),用逗号隔开。 + ] + }, + "up_mbps": 100, + "down_mbps": 100, + "alpn": "h3" //alpn标签(选配)。传输协议选UDP,推荐alpn标签配置为h3。 +} diff --git a/Hysteria/outside_config.json b/Hysteria/outside_config.json new file mode 100644 index 00000000000..395fb7ae30e --- /dev/null +++ b/Hysteria/outside_config.json @@ -0,0 +1,16 @@ +{ + "listen": ":2083", //监听端口 + "protocol": "udp", //留空或"udp","wechat-video","faketcp" + "cert": "/home/tls/xx.yy/xx.yy.crt", //换成自己的证书,绝对路径。 + "key": "/home/tls/xx.yy/xx.yy.key", //换成自己的密钥,绝对路径。 + "obfs": "obfs2083", //修改为自己的混淆密码 + "auth": { //验证配置(此部分选配)。客户端或服务端性能很垃圾,推荐不配置此部分参数。 + "mode": "password", //验证模式,目前支持"none","passwords","external"。普通用户不推荐使用external(外部验证接入)验证模式。 + "config": [ + "diy2083" //修改为自己的验证密钥,验证密钥可多组("password"),用逗号隔开。 + ] + }, + "up_mbps": 100, + "down_mbps": 100, + "alpn": "h3" //alpn标签(选配)。传输协议选UDP,推荐alpn标签配置为h3。 +} diff --git a/NaiveProxy(Caddy+forwardproxy)/README.md b/NaiveProxy(Caddy+forwardproxy)/README.md new file mode 100644 index 00000000000..28a573f17f6 --- /dev/null +++ b/NaiveProxy(Caddy+forwardproxy)/README.md @@ -0,0 +1,11 @@ +介绍: + +本示例使用 Caddy 源码加改进版 forwardproxy 插件编译而成 Caddy 文件,实现了 NaiveProxy 服务端加伪装网站应用。 + +注意: + +1、使用本人 Releases 中编译好的 Caddy 文件,可支持 NaiveProxy 等应用。 + +2、本示例 NaiveProxy 除了支持 HTTP/2 代理应用,还同时支持 HTTP/3 代理应用,即 QUIC 协议传输。若 NaiveProxy 使用 HTTP/3 代理应用,建议增加 [UDP 接收缓冲区大小](https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size)。 + +3、本示例 Caddy 支持自动 HTTPS,即自动申请与更新 TLS 证书,自动 HTTP 重定向到 HTTPS。 diff --git a/NaiveProxy(Caddy+forwardproxy)/caddy.json b/NaiveProxy(Caddy+forwardproxy)/caddy.json new file mode 100644 index 00000000000..9138c5d7c57 --- /dev/null +++ b/NaiveProxy(Caddy+forwardproxy)/caddy.json @@ -0,0 +1,87 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "apps": { + "http": { + "servers": { + "https": { + "listen": [":443"], + "routes": [{ + "handle": [{ + "handler": "forward_proxy", + "auth_user_deprecated": "user", //NaiveProxy用户,修改为自己的。 + "auth_pass_deprecated": "pass", //NaiveProxy密码,修改为自己的。 + "hide_ip": true, + "hide_via": true, + "probe_resistance": {} + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["h2.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["h3.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "protocols": ["h1","h2","h3"] //默认配置 + } + } + }, + "tls": { + "certificates": { + "automate": ["h2.xx.yy","h3.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//3、本配置使用非AES算法的密码套件配置(h2.xx.yy)来避免被封。NaiveProxy使用HTTPS协议时用h2.xx.yy域名,使用QUIC协议时用h3.xx.yy域名。 diff --git a/README.md b/README.md new file mode 100644 index 00000000000..0b4aef6786a --- /dev/null +++ b/README.md @@ -0,0 +1,93 @@ +**这里是分享怎么搭建主流科学上网的优化配置及最优组合示例(如是不太了解科学上网,建议先依次从简单到复杂参考及部署。),其特点如下:** +1. 实现了SNI分流使用Local Loopback连接或使用Unix Donew Socket(UDS)连接及启用PROXY protocol支持。 +2. 实现了反代使用Local Loopback连接或使用Unix Donew Socket(UDS)连接支持。 +3. 实现了回落/分流使用Local Loopback连接或使用Unix Donew Socket(UDS)连接及启用PROXY protocol支持。 +4. 实现了Caddy、V2Ray/Xray使用UDS连接时采用Abstract sockets模式(不需考虑权限问题)。 +5. 实现了Nginx SNI分流(TCP转发)与定向UDP转发配合以支持SNI分流后的NaiveProxy HTTP/3代理应用。 +6. 实现了使用json配置Caddy SNI分流,且可针对分流端口或进程是否开启PROXY protocol发送。 +7. 实现了Caddy与相关应用的TLS证书申请与更新全自动化。 +8. 实现了服务端综合应用配置示例中使用mKCP、WebSocket、HTTP/2、gRPC传输方式的应用配置可删、可换、可增(REALITY H2/gRPC应用除外),灵活组合而不影响整体架构。 +9. 实现了除V2Ray/Xray mKCP与Hysteria应用之外,其它应用对外都使用443端口,各应用互不影响。 +10. 实现了正常应用与CDN流量中转(基于WebSocket over TLS或基于gRPC over TLS)同时使用。 +11. 实现了除V2Ray/Xray的mKCP应用与Hysteria应用之外,其它应用都支持流量伪装与防探测,且提供流量伪装与防探测的回落或代理网站都支持HTTP自动跳转到HTTPS,SSL/TLS安全评估报告为A+(非AES算法的密码套件配置示例除外)等,即所有特征完全与真实网站一致。 + +### 服务端单一/简单应用配置示例 +####  V2Ray/Xray的mKCP应用与Hysteria应用 +1. [V2Ray(VLESS\VMess+mKCP+seed)](https://github.com/lxhao61/integrated-examples/tree/new/V2Ray(VLESS%5CVMess%2BmKCP%2Bseed))(VLESS/VMess+mKCP+seed应用。VLESS+mKCP+seed标记为A。) +2. [Hysteria](https://github.com/lxhao61/integrated-examples/tree/new/Hysteria)(基于QUIC协议修改的双边加速代理应用。) +####  反代V2Ray/Xray的WebSocket应用 +1. [V2Ray(VMess+WebSocket)+Caddy\Nginx](https://github.com/lxhao61/integrated-examples/tree/new/V2Ray(VMess%2BWebSocket)%2BCaddy%5CNginx)(VMess+WebSocket+TLS应用。标记为B。) +2. [V2Ray(SS+Door+WebSocket)+Caddy](https://github.com/lxhao61/integrated-examples/tree/new/V2Ray(SS%2BDoor%2BWebSocket)%2BCaddy%5CNginx)(兼容Shadowsocks加v2ray-plugin插件的websocket-tls应用。) +3. [V2Ray(VLESS+WebSocket)+Caddy\Nginx](https://github.com/lxhao61/integrated-examples/tree/new/V2Ray(VLESS%2BWebSocket)%2BCaddy%5CNginx)(VLESS+WebSocket+TLS应用。) +4. [V2Ray(Trojan+WebSocket)+Caddy\Nginx](https://github.com/lxhao61/integrated-examples/tree/new/V2Ray(Trojan%2BWebSocket)%2BCaddy%5CNginx)(Trojan+WebSocket+TLS应用。) +####  反代V2Ray/Xray的H2C应用 +1. [V2Ray(VLESS+H2C)+Caddy](https://github.com/lxhao61/integrated-examples/tree/new/V2Ray(VLESS%2BH2C)%2BCaddy)(VLESS+H2C+TLS应用。标记为D。) +2. [V2Ray(Trojan+H2C)+Caddy](https://github.com/lxhao61/integrated-examples/tree/new/V2Ray(Trojan%2BH2C)%2BCaddy)(Trojan+H2C+TLS应用。) +####  反代V2Ray/Xray的gRPC应用 +1. [V2Ray(VMess+gRPC)+Caddy\Nginx](https://github.com/lxhao61/integrated-examples/tree/new/V2Ray(VMess%2BgRPC)%2BCaddy%5CNginx)(VMess+gRPC+TLS应用。) +2. [V2Ray(SS+gRPC)+Caddy\Nginx](https://github.com/lxhao61/integrated-examples/tree/new/V2Ray(SS%2BgRPC)%2BCaddy%5CNginx)(兼容Shadowsocks加v2ray-plugin插件的grpc-tls应用。标记为G。) +3. [V2Ray(VLESS+gRPC)+Caddy\Nginx](https://github.com/lxhao61/integrated-examples/tree/new/V2Ray(VLESS%2BgRPC)%2BCaddy%5CNginx)(VLESS+gRPC+TLS应用。) +4. [V2Ray(Trojan+gRPC)+Caddy\Nginx](https://github.com/lxhao61/integrated-examples/tree/new/V2Ray(Trojan%2BgRPC)%2BCaddy%5CNginx)(Trojan+gRPC+TLS应用。) +####  Xray的Trojan回落应用 +1. [Xray(Trojan+TCP+TLS)+Nginx](https://github.com/lxhao61/integrated-examples/tree/new/Xray(Trojan%2BTCP%2BTLS)%2BNginx)(Trojan+TCP+TLS回落Nginx应用。标记为F。) +2. [Xray(Trojan+TCP+TLS)+Caddy](https://github.com/lxhao61/integrated-examples/tree/new/Xray(Trojan%2BTCP%2BTLS)%2BCaddy)(Trojan+TCP+TLS回落Caddy应用。标记为F。) +####  Xray的XTLS Vision应用 +1. [Xray(VLESS+Vision+TLS)+Nginx](https://github.com/lxhao61/integrated-examples/tree/new/Xray(VLESS%2BVision%2BTLS)%2BNginx)(VLESS+Vision+TLS回落Nginx。标记为E。) +2. [Xray(VLESS+Vision+TLS)+Caddy](https://github.com/lxhao61/integrated-examples/tree/new/Xray(VLESS%2BVision%2BTLS)%2BCaddy)(VLESS+Vision+TLS回落Caddy。标记为E。) +####  Caddy插件应用 +1. [NaiveProxy(Caddy+forwardproxy)](https://github.com/lxhao61/integrated-examples/tree/new/NaiveProxy(Caddy%2Bforwardproxy))(基于Caddy插件的NaiveProxy应用。标记为N。) +2. [Trojan-Go(Caddy+caddy-trojan)](https://github.com/lxhao61/integrated-examples/tree/new/Trojan-Go(Caddy%2Bcaddy-trojan))(基于Caddy插件的Trojan-Go应用。标记为T。) +3. [Caddy(N+T)](https://github.com/lxhao61/integrated-examples/tree/new/Caddy(N%2BT))(基于Caddy插件的NaiveProxy与Trojan-Go应用。) +####  Xray的REALITY H2/gRPC应用 +1. [Xray(VLESS+H2C+REALITY)](https://github.com/lxhao61/integrated-examples/tree/new/Xray(VLESS%2BH2C%2BREALITY))(VLESS+H2C+REALITY应用。标记为K。) +2. [Xray(SS+gRPC+REALITY)](https://github.com/lxhao61/integrated-examples/tree/new/Xray(SS%2BgRPC%2BREALITY))(Shadowsocks+gRPC+REALITY应用。) +####  Xray的REALITY Vision应用 +1. [Xray(VLESS+Vision+REALITY)](https://github.com/lxhao61/integrated-examples/tree/new/Xray(VLESS%2BVision%2BREALITY))(VLESS+Vision+REALITY应用。标记为M。) +2. [Xray(M+K)](https://github.com/lxhao61/integrated-examples/tree/new/Xray(M+K))(VLESS+Vision+REALITY与VLESS+H2C+REALITY共用端口应用。) + +### 服务端综合应用配置示例 +####  以反代为核心的综合应用 +1. [V2Ray(B+G+A)+Nginx](https://github.com/lxhao61/integrated-examples/tree/new/V2Ray(B%2BG%2BA)%2BNginx)(反代WebSocket、gRPC的综合应用。) +2. [V2Ray(B+D+G+A)+Caddy(N+T)](https://github.com/lxhao61/integrated-examples/tree/new/V2Ray(B%2BD%2BG%2BA)%2BCaddy(N%2BT))(反代WebSocket、H2C、gRPC加NaiveProxy与Trojian-Go的综合应用。) +####  以XTLS Vision为核心的综合应用 +1. [Xray(E+B+G+A)+Nginx](https://github.com/lxhao61/integrated-examples/tree/new/Xray(E%2BB%2BG%2BA)%2BNginx)(以VLESS回落Nginx为核心的综合应用。) +2. [Xray(E+B+D+G+A)+Caddy(N)](https://github.com/lxhao61/integrated-examples/tree/new/Xray(E%2BB%2BD%2BG%2BA)%2BCaddy(N))(以VLESS回落Caddy为核心的综合应用。) +####  以REALITY Vision为核心的综合应用 +1. [Xray(M+K+B+G+A)+Nginx](https://github.com/lxhao61/integrated-examples/tree/new/Xray(M%2BK%2BB%2BG%2BA)%2BNginx)(由Nginx提供网站实现以REALITY Vision为核心的综合应用。) +2. [Xray(M+K+B+G+A)+Caddy(N+T)](https://github.com/lxhao61/integrated-examples/tree/new/Xray(M%2BK%2BB%2BG%2BA)%2BCaddy(N%2BT))(由Caddy提供网站实现以REALITY Vision为核心的综合应用。) +####  由Nginx/Caddy兼顾SNI分流实现XTLS Vision与Trojan回落为核心的综合应用 +1. [Xray(E+F+B+G+A)+Nginx](https://github.com/lxhao61/integrated-examples/tree/new/Xray(E%2BF%2BB%2BG%2BA)%2BNginx)(由Nginx兼顾SNI分流实现的综合应用。) +2. [Xray(E+F+B+D+G+A)+Caddy(N)](https://github.com/lxhao61/integrated-examples/tree/new/Xray(E%2BF%2BB%2BD%2BG%2BA)%2BCaddy(N))(由Caddy兼顾SNI分流实现的综合应用。) +####  由Nginx/Caddy兼顾SNI分流实现REALITY Vision与Trojan回落为核心的综合应用 +1. [Xray(M+K+F+B+G+A)+Nginx](https://github.com/lxhao61/integrated-examples/tree/new/Xray(M%2BK%2BF%2BB%2BG%2BA)%2BNginx)(由Nginx兼顾SNI分流实现的综合应用。) +2. [Xray(M+K+F+B+G+A)+Caddy(N)](https://github.com/lxhao61/integrated-examples/tree/new/Xray(M%2BK%2BF%2BB%2BG%2BA)%2BCaddy(N))(由Caddy兼顾SNI分流实现的综合应用。) +####  由Nginx专职SNI分流实现兼顾各方优势的综合应用 +1. [Xray(E+F+B+D+G+A)+Caddy(N)+Nginx](https://github.com/lxhao61/integrated-examples/tree/new/Xray(E%2BF%2BB%2BD%2BG%2BA)%2BCaddy(N)%2BNginx)(以XTLS Vision为核心的综合应用。) +2. [Xray(M+K+F+B+G+A)+Caddy(N)+Nginx](https://github.com/lxhao61/integrated-examples/tree/new/Xray(M%2BK%2BF%2BB%2BG%2BA)%2BCaddy(N)%2BNginx)(以REALITY Vision为核心的综合应用。) +####  注意(以上所有示例): +1. Xray是V2Ray的超集,更好的整体性能和独有的XTLS Vision(主要解决TLS in TLS问题)、REALITY(主要解决基于SNI名单阻断问题)等一系列应用增强,且完全兼容V2Ray的v4版。 +2. V2Ray/Xray示例中各应用都配置了禁用BT。如不需要,参考‘V2Ray(Other Configuration)’中BT_config.json示例删除相关配置。 +3. V2Ray/Xray单一核心应用简记:A=VLESS+mKCP+seed、B=VMess+WebSocket+TLS、D=VLESS+H2C+TLS、E=VLESS+Vision+TLS、F=Trojan+TCP+TLS、G=Shadowsocks+gRPC+TLS、K=VLESS+H2C+REALITY、M=VLESS+Vision+REALITY。 +4. Caddy插件单一应用简记:N=NaiveProxy(Caddy+forwardproxy)、T=Trojan-Go(Caddy+caddy-trojan)。 +5. 受限应用条件及场景,NaiveProxy的QUIC应用(即Caddy的HTTP/3代理应用)不是所有相关NaiveProxy示例都支持。 +6. 目前Caddy从Let's Encrypt或ZeroSSL自动申请的TLS证书默认都为ECC证书。 +7. 综合应用配置示例中使用mKCP、WebSocket、HTTP/2、gRPC传输方式的应用配置可删、可换、可增(REALITY H2/gRPC应用除外);参考‘服务端单一/简单应用配置示例’中对应配置示例修改。 +8. 当前不推荐使用WebSocket传输方式的应用直接科学上网,套CDN使用无碍。若CDN流量中转(基于WebSocket over TLS或基于gRPC over TLS)使用不可信的CDN进行中转,V2Ray/Xray示例推荐使用自身带加密的VMess或Shadowsocks协议配置;否则推荐使用自身不带加密的VLESS或Trojan协议配置。 +9. 针对V2Ray特性,当前服务端配置推荐使用非AES算法密码套件配置示例,客户端开启uTLS指纹。 针对Xray特性,当前服务端配置依次推荐使用REALITY Vision配置示例、XTLS Vision配置示例、非AES算法的密码套件配置示例、REALITY配置示例,客户端开启uTLS指纹。 +10. 流量伪装与防探测网站可由其它WEB应用软件实现,其支持反代(WebSocket、gRPC及H2C)与支持回落(H2C server及HTTP/1.1 server)取决于自身,自行参考Caddy或Nginx对应配置示例。 +11. 附加相关插件的Caddy程序文件已编译好,去本人Releases中下载即可。 +12. Trojan-Go安卓手机客户端可以去本人Releases中下载(最末)。 + +### 服务端特殊应用配置示例 +1. [V2Ray(Other Configuration)](https://github.com/lxhao61/integrated-examples/tree/new/V2Ray(Other%20Configuration)) (V2Ray或Xray的特色应用配置方法。) +2. [Caddy(Other Configuration)](https://github.com/lxhao61/integrated-examples/tree/new/Caddy(Other%20Configuration)) (Caddy的特色应用配置方法。) + +### 原版客户端配置示例 + [Client Configuration](https://github.com/lxhao61/integrated-examples/tree/new/Client%20Configuration)(若使用第三方客户端参考即可。) + +### systemd服务文件 + [Service Configuration](https://github.com/lxhao61/integrated-examples/tree/new/Service%20Configuration)(配置软件服务由systemd管理。) + +### 使用/贡献指南 +1. 若科学上网相关软件增加新功能,开始在服务端单一应用配置示例中添加;过一段时间(测试及验证稳定后)才会服务端综合应用配置示例中添加。 +2. 欢迎你提交 PR,如对现行配置示例优化修订,或将自己使用的配置制作模板提交等。 diff --git a/Service Configuration/README.md b/Service Configuration/README.md new file mode 100644 index 00000000000..68b12351832 --- /dev/null +++ b/Service Configuration/README.md @@ -0,0 +1,7 @@ +介绍: + +此目录包含 V2Ray、Xray、Nginx、Caddy、Hysteria 的 service 配置示例,以便参考及手工配置 systemd 服务。 + +注意: + +配置示例中的名称及路径等修改为自己配置即可。 diff --git a/Service Configuration/caddy.service b/Service Configuration/caddy.service new file mode 100644 index 00000000000..19ab14b8f02 --- /dev/null +++ b/Service Configuration/caddy.service @@ -0,0 +1,21 @@ +[Unit] +Description=Caddy +Documentation=https://caddyserver.com/docs/ +After=network.target network-online.target +Requires=network-online.target + +[Service] +Type=notify +User=root //默认以root用户运行。若修改,请修改为相应权限的用户。 +Group=root //默认以root组运行。若修改,请修改为相应权限的组。 +ExecStart=/usr/local/bin/caddy/caddy run --environ --config /usr/local/etc/caddy/caddy.json //json配置调用。如是Caddyfile配置,直接修改caddy.json为Caddyfile即可。 +ExecReload=/usr/local/bin/caddy/caddy reload --config /usr/local/etc/caddy/caddy.json --force //json配置调用。如是Caddyfile配置,直接修改caddy.json为Caddyfile即可。 +TimeoutStopSec=5s +LimitNOFILE=1048576 +LimitNPROC=512 +PrivateTmp=true +ProtectSystem=full +AmbientCapabilities=CAP_NET_BIND_SERVICE + +[Install] +WantedBy=multi-user.target diff --git a/Service Configuration/hysteria.service b/Service Configuration/hysteria.service new file mode 100644 index 00000000000..99166ab7fe6 --- /dev/null +++ b/Service Configuration/hysteria.service @@ -0,0 +1,17 @@ +[Unit] +Description=Hysteria, a feature-packed network utility optimized for networks of poor quality +Documentation=https://github.com/HyNetwork/hysteria/wiki +After=network.target + +[Service] +User=root //默认以root用户运行。若修改,请修改为相应权限的用户。 +CapabilityBoundingSet=CAP_NET_RAW CAP_NET_BIND_SERVICE +AmbientCapabilities=CAP_NET_RAW CAP_NET_BIND_SERVICE +NoNewPrivileges=true +ExecStart=/usr/local/bin/hysteria/hysteria -config /usr/local/etc/hysteria/config.json server +Restart=on-failure +RestartPreventExitStatus=1 +RestartSec=5 + +[Install] +WantedBy=multi-user.target diff --git a/Service Configuration/nginx.service b/Service Configuration/nginx.service new file mode 100644 index 00000000000..4cdc0436193 --- /dev/null +++ b/Service Configuration/nginx.service @@ -0,0 +1,15 @@ +[Unit] +Description=The NGINX HTTP and reverse proxy server +After=syslog.target network.target remote-fs.target nss-lookup.target + +[Service] +Type=forking +PIDFile=/usr/local/bin/nginx/nginx.pid +ExecStartPre=/usr/local/bin/nginx/nginx -t +ExecStart=/usr/local/bin/nginx/nginx -c /usr/local/etc/nginx/nginx.conf +ExecReload=/usr/local/bin/nginx/nginx -s reload +ExecStop=/bin/kill -s QUIT $MAINPID +PrivateTmp=true + +[Install] +WantedBy=multi-user.target diff --git a/Service Configuration/v2ray.service b/Service Configuration/v2ray.service new file mode 100644 index 00000000000..1c99a4e87db --- /dev/null +++ b/Service Configuration/v2ray.service @@ -0,0 +1,16 @@ +[Unit] +Description=V2Ray Service +Documentation=https://www.v2fly.org/ +After=network.target nss-lookup.target + +[Service] +User=root //默认以root用户运行。若修改,请修改为相应权限的用户。 +CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE +AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE +NoNewPrivileges=true +ExecStart=/usr/local/bin/v2ray/v2ray -config /usr/local/etc/v2ray/config.json +Restart=on-failure +RestartPreventExitStatus=23 + +[Install] +WantedBy=multi-user.target diff --git a/Service Configuration/xray.service b/Service Configuration/xray.service new file mode 100644 index 00000000000..eda28f15744 --- /dev/null +++ b/Service Configuration/xray.service @@ -0,0 +1,18 @@ +[Unit] +Description=Xray Service +Documentation=https://github.com/xtls +After=network.target nss-lookup.target + +[Service] +User=root //默认以root用户运行。若修改,请修改为相应权限的用户。 +CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE +AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE +NoNewPrivileges=true +ExecStart=/usr/local/bin/xray/xray run -config /usr/local/etc/xray/config.json +Restart=on-failure +RestartPreventExitStatus=23 +LimitNPROC=10000 +LimitNOFILE=1000000 + +[Install] +WantedBy=multi-user.target diff --git a/Trojan-Go(Caddy+caddy-trojan)/README.md b/Trojan-Go(Caddy+caddy-trojan)/README.md new file mode 100644 index 00000000000..d123d5fcbb4 --- /dev/null +++ b/Trojan-Go(Caddy+caddy-trojan)/README.md @@ -0,0 +1,11 @@ +介绍: + +本示例使用 Caddy 源码加 caddy-trojan 插件编译而成 Caddy 文件,仅一个软件就实现了 Trojan-Go 服务端加伪装网站应用。 + +注意: + +1、使用本人 Releases 中编译好的 Caddy 文件,可支持 Trojan-Go 等应用。 + +2、本示例 Trojan-Go 仅兼容原版服务端的核心应用:支持 Trojan 应用与 Trojan-Go 的 WebSocket 应用共存,支持 CDN 流量中转(基于 WebSocket over TLS)。客户端推荐选择 Xray 客户端,支持使用指纹伪造;WebSocket 应用不能启用 WebSocket 0-RTT 与多路复用,不兼容。 + +3、本示例 Caddy 支持自动 HTTPS,即自动申请与更新 TLS 证书,自动 HTTP 重定向到 HTTPS。 diff --git a/Trojan-Go(Caddy+caddy-trojan)/caddy.json b/Trojan-Go(Caddy+caddy-trojan)/caddy.json new file mode 100644 index 00000000000..4d41da147b1 --- /dev/null +++ b/Trojan-Go(Caddy+caddy-trojan)/caddy.json @@ -0,0 +1,101 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "apps": { + "http": { + "servers": { + "https": { + "listen": [":443"], + "listener_wrappers": [{ + "wrapper": "trojan" //caddy-trojan插件应用必须配置 + }], + "routes": [{ + "handle": [{ + "handler": "trojan", + "connect_method": true, + "websocket": true + }] + }, //此部分配置为caddy-trojan插件的WebSocket应用,若删除就仅支持Trojan应用。 + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["z2.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2"] + } + } + }, + "trojan": { + "proxy": { + "proxy": "no_proxy" + }, + "upstream": { + "upstream": "memory" + }, + "users": ["diy443"] //修改为自己的密码。密码可多组("password"),用逗号隔开。 + }, + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//3、本配置使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。Trojan-Go使用Trojan应用时用z1.xx.yy域名,使用WebSocket应用时用z2.xx.yy域名。 diff --git a/V2Ray(B+D+G+A)+Caddy(N+T)/1_caddy.json b/V2Ray(B+D+G+A)+Caddy(N+T)/1_caddy.json new file mode 100644 index 00000000000..4000091ad4b --- /dev/null +++ b/V2Ray(B+D+G+A)+Caddy(N+T)/1_caddy.json @@ -0,0 +1,170 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "apps": { + "http": { + "servers": { + "https": { + "listen": [":443"], + "listener_wrappers": [{ + "wrapper": "trojan" //caddy-trojan插件应用必须配置 + }], + "routes": [{ + "match": [{ + "path": ["/HALdGZ9k"], //与VMess+WebSocket应用中path对应 + "header": { + "Connection": ["*Upgrade*"], + "Upgrade": ["websocket"] + } + }], + "handle": [{ + "handler": "reverse_proxy", + "upstreams": [{ + "dial": "127.0.0.1:2001" //转发给本机VMess+WebSocket监听端口 + }] + }] + }, + { + "match": [{ + "path": ["/SeuW56Es"] //与VLESS+H2C应用中path对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2005" //转发给本机VLESS+H2C监听端口 + }] + }] + }, + { + "match": [{ + "protocol": "grpc", + "path": ["/SALdGZ9k/*"] //与Shadowsocks+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2011" //转发给本机Shadowsocks+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "forward_proxy", + "auth_user_deprecated": "user", //NaiveProxy用户,修改为自己的。 + "auth_pass_deprecated": "pass", //NaiveProxy密码,修改为自己的。 + "hide_ip": true, + "hide_via": true, + "probe_resistance": {} + }] + }, + { + "handle": [{ + "handler": "trojan", + "connect_method": true, + "websocket": true + }] + }, //此部分配置为caddy-trojan插件的WebSocket应用,若删除就仅支持Trojan应用。 + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["z2.xx.yy","h3.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2","h3"] //默认配置 + } + } + }, + "trojan": { + "proxy": { + "proxy": "no_proxy" + }, + "upstream": { + "upstream": "memory" + }, + "users": ["diy443"] //修改为自己的密码。密码可多组("password"),用逗号隔开。 + }, + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy","h3.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//3、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 +//4、本示例使用不同域名来实现介绍中各应用,其办法如下: +//1)、VMess+WebSocket+TLS仅使用z2.xx.yy域名。 +//2)、VLESS+H2C+TLS仅使用z1.xx.yy域名。 +//3)、Shadowsocks+gRPC+TLS可使用z1.xx.yy域名或z2.xx.yy域名,推荐使用z1.xx.yy域名。 +//4)、NaiveProxy使用HTTPS协议时用z1.xx.yy域名,使用QUIC协议时用h3.xx.yy域名。 +//5)、Trojan-Go使用Trojan应用时用z1.xx.yy域名,使用WebSocket应用时用z2.xx.yy域名。 diff --git a/V2Ray(B+D+G+A)+Caddy(N+T)/1_v2ray_config.json b/V2Ray(B+D+G+A)+Caddy(N+T)/1_v2ray_config.json new file mode 100644 index 00000000000..5e8189b8e7e --- /dev/null +++ b/V2Ray(B+D+G+A)+Caddy(N+T)/1_v2ray_config.json @@ -0,0 +1,140 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2001, //VMess+WebSocket监听端口 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2005, //VLESS+H2C监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "httpSettings": { + "path": "/SeuW56Es" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/V2Ray(B+D+G+A)+Caddy(N+T)/2_caddy.json b/V2Ray(B+D+G+A)+Caddy(N+T)/2_caddy.json new file mode 100644 index 00000000000..562d26a7c61 --- /dev/null +++ b/V2Ray(B+D+G+A)+Caddy(N+T)/2_caddy.json @@ -0,0 +1,170 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "apps": { + "http": { + "servers": { + "https": { + "listen": [":443"], + "listener_wrappers": [{ + "wrapper": "trojan" //caddy-trojan插件应用必须配置 + }], + "routes": [{ + "match": [{ + "path": ["/HALdGZ9k"], //与VMess+WebSocket应用中path对应 + "header": { + "Connection": ["*Upgrade*"], + "Upgrade": ["websocket"] + } + }], + "handle": [{ + "handler": "reverse_proxy", + "upstreams": [{ + "dial": "unix/@vmessws" //转发给本机VMess+WebSocket监听进程 + }] + }] + }, + { + "match": [{ + "path": ["/SeuW56Es"] //与VLESS+H2C应用中path对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "unix/@vlessh2c" //转发给本机VLESS+H2C监听进程 + }] + }] + }, + { + "match": [{ + "protocol": "grpc", + "path": ["/SALdGZ9k/*"] //与Shadowsocks+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2011" //转发给本机Shadowsocks+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "forward_proxy", + "auth_user_deprecated": "user", //NaiveProxy用户,修改为自己的。 + "auth_pass_deprecated": "pass", //NaiveProxy密码,修改为自己的。 + "hide_ip": true, + "hide_via": true, + "probe_resistance": {} + }] + }, + { + "handle": [{ + "handler": "trojan", + "connect_method": true, + "websocket": true + }] + }, //此部分配置为caddy-trojan插件的WebSocket应用,若删除就仅支持Trojan应用。 + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["z2.xx.yy","h3.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2","h3"] //默认配置 + } + } + }, + "trojan": { + "proxy": { + "proxy": "no_proxy" + }, + "upstream": { + "upstream": "memory" + }, + "users": ["diy443"] //修改为自己的密码。密码可多组("password"),用逗号隔开。 + }, + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy","h3.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//3、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 +//4、本示例使用不同域名来实现介绍中各应用,其办法如下: +//1)、VMess+WebSocket+TLS仅使用z2.xx.yy域名。 +//2)、VLESS+H2C+TLS仅使用z1.xx.yy域名。 +//3)、Shadowsocks+gRPC+TLS可使用z1.xx.yy域名或z2.xx.yy域名,推荐使用z1.xx.yy域名。 +//4)、NaiveProxy使用HTTPS协议时用z1.xx.yy域名,使用QUIC协议时用h3.xx.yy域名。 +//5)、Trojan-Go使用Trojan应用时用z1.xx.yy域名,使用WebSocket应用时用z2.xx.yy域名。 diff --git a/V2Ray(B+D+G+A)+Caddy(N+T)/2_v2ray_config.json b/V2Ray(B+D+G+A)+Caddy(N+T)/2_v2ray_config.json new file mode 100644 index 00000000000..c591604f2fd --- /dev/null +++ b/V2Ray(B+D+G+A)+Caddy(N+T)/2_v2ray_config.json @@ -0,0 +1,138 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "@vmessws", //VMess+WebSocket监听进程 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@vlessh2c", //VLESS+H2C监听进程 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "httpSettings": { + "path": "/SeuW56Es" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/V2Ray(B+D+G+A)+Caddy(N+T)/README.md b/V2Ray(B+D+G+A)+Caddy(N+T)/README.md new file mode 100644 index 00000000000..9c9036a9d9d --- /dev/null +++ b/V2Ray(B+D+G+A)+Caddy(N+T)/README.md @@ -0,0 +1,33 @@ +介绍: + +利用 Caddy 支持 WebSocket、H2C、gRPC 代理与 forwardproxy、caddy-trojan 插件应用,实现除 V2Ray 或 Xray 的 mKCP 应用外,WebSocket、H2C、gRPC 三种类型的反向代理应用与 forwardproxy、caddy-trojan 插件应用共用443端口,其应用如下: + +1、B=VMess+WebSocket+TLS(TLS 由 Caddy 提供及处理,不需配置。) + +2、D=VLESS+H2C+TLS(TLS 由 Caddy 提供及处理,不需配置。) + +3、G=Shadowsocks+gRPC+TLS(TLS 由 Caddy 提供及处理,不需配置。) + +4、A=VLESS+mKCP+seed + +5、N=NaiveProxy(基于 Caddy 的改进版 forwardproxy 插件实现,TLS 由 Caddy 提供及处理。) + +6、T=Trojan-Go(基于 Caddy 的 caddy-trojan 插件实现,TLS 由 Caddy 提供及处理。) + +注意: + +1、V2Ray 或 Xray 的监听地址不支持 Shadowsocks 协议使用 UDS 监听。 + +2、V2Ray 版本不小于 v4.36.2 或 Xray 版本不小于 v1.4.0 才支持 gRPC 传输方式。 + +3、Caddy 版本不小于 v2.6.0 才支持 H2C/gRPC proxy 的 UDS 转发。 + +4、使用本人 Releases 中编译好的 Caddy 文件,可同时支持 H2C/gRPC proxy、Trojan-Go、NaiveProxy 等应用。 + +5、本示例 NaiveProxy 除了支持 HTTP/2 代理应用,还同时支持 HTTP/3 代理应用,即 QUIC 协议传输。若 NaiveProxy 使用 HTTP/3 代理应用,建议增加 [UDP 接收缓冲区大小](https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size)。 + +6、本示例 Trojan-Go 仅推荐使用 Trojan 应用(不使用 WebSocket 应用):因为已有同类 WebSocket 应用,且其 WebSocket 应用不支持 WebSocket 0-RTT 与多路复用等;另外还可使用 [Trojan+WebSocket+TLS](https://github.com/lxhao61/integrated-examples/tree/main/V2Ray(Trojan%2BWebSocket)%2BCaddy%5CNginx) 应用替代,性能及兼容性更好。客户端推荐选择 Xray 客户端,支持使用指纹伪造。 + +7、本示例 Caddy 支持自动 HTTPS,即自动申请与更新 TLS 证书,自动 HTTP 重定向到 HTTPS。 + +8、配置1:使用 Local Loopback 连接。配置2:使用 UDS 连接(对应 Shadowsocks+gRPC+TLS 除外)。 diff --git a/V2Ray(B+D+G+A)+Caddy(N+T)/xray_SS-2022_config.json b/V2Ray(B+D+G+A)+Caddy(N+T)/xray_SS-2022_config.json new file mode 100644 index 00000000000..87803a31d96 --- /dev/null +++ b/V2Ray(B+D+G+A)+Caddy(N+T)/xray_SS-2022_config.json @@ -0,0 +1,46 @@ +//Shadowsocks-2022配置 +//原配置: +//........<省略>........ + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//以上配置修改为如下: +//单用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-chacha20-poly1305", //Shadowsocks-2022加密方法之一 + "password": "81qjRtwJZWx2gBphrLk18WZQ06B3Y2Vxlnqe903xXqU=", //修改为自己的密钥 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//多用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-aes-128-gcm", //Shadowsocks-2022加密方法之一 + "password": "rvQ6fK6Y4ckgFVslZlZUgQ==", //修改为自己的主项密钥 + "clients": [ + { + "password": "FPTg9fyNve167Fg8oPkFlQ==", //修改为自己的分项密钥 + "email": "2011@gmail.com" + }, + { + "password": "dkv04xu1f+UeM3mXpNJgVA==", //修改为自己的分项密钥 + "email": "2021@gmail.com" + } + ] + }, +//........<省略>........ +//备注: +//1、Xray从v1.5.9版开始支持Shadowsocks-2022。 +//2、密钥生成及长度 +//在服务器上直接使用‘openssl rand -base64 <长度> ’命令生成符合如下加密方法的对应密钥。 +// 加密方法 密钥长度 +//2022-blake3-aes-128-gcm 16 +//2022-blake3-aes-256-gcm 32 +//2022-blake3-chacha20-poly1305 32 +//3、多用户的客户端的密钥为主项密钥:分项密钥的组合,如rvQ6fK6Y4ckgFVslZlZUgQ==:FPTg9fyNve167Fg8oPkFlQ==。 diff --git a/V2Ray(B+G+A)+Nginx/1_nginx.conf b/V2Ray(B+G+A)+Nginx/1_nginx.conf new file mode 100644 index 00000000000..a5264cf14fc --- /dev/null +++ b/V2Ray(B+G+A)+Nginx/1_nginx.conf @@ -0,0 +1,126 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 443 ssl http2 default_server; + listen [::]:443 ssl http2 default_server; #无IPv6,此项可以删除。 + ssl_protocols TLSv1.2; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + server_name z1.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z1.xx.yy/z1.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z1.xx.yy/z1.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2; + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305; #非AES算法的密码套件。若证书为RSA证书,ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + include nginx_real.conf; #插入nginx_real.conf配置文件(real应用配置块,实现套CDN的应用的访问IP还原为客户端原始IP。选配,套CDN配置。) + server_name z2.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z2.xx.yy/z2.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z2.xx.yy/z2.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location = /HALdGZ9k { #与VMess+WebSocket应用中path对应 + if ($http_upgrade != "websocket") { + return 404; + } #WebSocket协商失败时返回404 + proxy_redirect off; + proxy_pass http://unix:/dev/shm/vmessws.sock; #转发给本机VMess+WebSocket监听进程 + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 +#2、本示例使用不同域名来实现介绍中各应用,其办法如下: +#1)、VMess+WebSocket+TLS仅使用z2.xx.yy域名。 +#2)、Shadowsocks+gRPC+TLS可使用z1.xx.yy域名或z2.xx.yy域名,推荐使用z1.xx.yy域名。 diff --git a/V2Ray(B+G+A)+Nginx/1_v2ray_config.json b/V2Ray(B+G+A)+Nginx/1_v2ray_config.json new file mode 100644 index 00000000000..1defe368157 --- /dev/null +++ b/V2Ray(B+G+A)+Nginx/1_v2ray_config.json @@ -0,0 +1,112 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2001, //VMess+WebSocket监听端口 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/V2Ray(B+G+A)+Nginx/2_nginx.conf b/V2Ray(B+G+A)+Nginx/2_nginx.conf new file mode 100644 index 00000000000..a5264cf14fc --- /dev/null +++ b/V2Ray(B+G+A)+Nginx/2_nginx.conf @@ -0,0 +1,126 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 443 ssl http2 default_server; + listen [::]:443 ssl http2 default_server; #无IPv6,此项可以删除。 + ssl_protocols TLSv1.2; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + server_name z1.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z1.xx.yy/z1.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z1.xx.yy/z1.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2; + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305; #非AES算法的密码套件。若证书为RSA证书,ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + include nginx_real.conf; #插入nginx_real.conf配置文件(real应用配置块,实现套CDN的应用的访问IP还原为客户端原始IP。选配,套CDN配置。) + server_name z2.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z2.xx.yy/z2.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z2.xx.yy/z2.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location = /HALdGZ9k { #与VMess+WebSocket应用中path对应 + if ($http_upgrade != "websocket") { + return 404; + } #WebSocket协商失败时返回404 + proxy_redirect off; + proxy_pass http://unix:/dev/shm/vmessws.sock; #转发给本机VMess+WebSocket监听进程 + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 +#2、本示例使用不同域名来实现介绍中各应用,其办法如下: +#1)、VMess+WebSocket+TLS仅使用z2.xx.yy域名。 +#2)、Shadowsocks+gRPC+TLS可使用z1.xx.yy域名或z2.xx.yy域名,推荐使用z1.xx.yy域名。 diff --git a/V2Ray(B+G+A)+Nginx/2_v2ray_config.json b/V2Ray(B+G+A)+Nginx/2_v2ray_config.json new file mode 100644 index 00000000000..24aceeb06ac --- /dev/null +++ b/V2Ray(B+G+A)+Nginx/2_v2ray_config.json @@ -0,0 +1,111 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "/dev/shm/vmessws.sock", //VMess+WebSocket监听进程 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/V2Ray(B+G+A)+Nginx/README.md b/V2Ray(B+G+A)+Nginx/README.md new file mode 100644 index 00000000000..77870bd3a4d --- /dev/null +++ b/V2Ray(B+G+A)+Nginx/README.md @@ -0,0 +1,25 @@ +介绍: + +利用 Nginx 支持 WebSocket、gRPC 代理,实现除 V2Ray 或 Xray 的 mKCP 应用外,WebSocket、gRPC 两种类型的反向代理应用共用 443 端口,其应用如下: + +1、B=VMess+WebSocket+TLS(TLS 由 Nginx 启用及处理,不需配置。) + +2、G=Shadowsocks+gRPC+TLS(TLS 由 Nginx 启用及处理,不需配置。) + +3、A=VLESS+mKCP+seed + +注意: + +1、V2Ray 或 Xray 的监听地址不支持 Shadowsocks 协议使用 UDS 监听。 + +2、V2Ray 版本不小于 v4.36.2 或 Xray 版本不小于 v1.4.0 才支持 gRPC 传输方式。 + +3、Nginx 支持不同站点共用 443 端口需要 Nginx 包含 stream_core_module 和 stream_ssl_preread_module 模块。 + +4、Nginx 支持 HTTPS server、HTTP/2 server 及 WebSocket proxy、gRPC proxy 需要 Nginx 包含 http_ssl_module 与 http_v2_module 模块及 OpenSSL 库。 + +5、Nginx 支持请求标头还原为真实客户端地址需要 Nginx 包含 http_realip_module 模块。 + +6、不要使用 ACME 客户端在采用本示例的服务器上以 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书,因 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书需监听 80 或 443 端口,从而与当前应用端口冲突。 + +7、配置1:使用 Local Loopback 连接。配置2:使用 UDS 连接(对应 Shadowsocks+gRPC+TLS 除外)。 diff --git a/V2Ray(B+G+A)+Nginx/nginx_real.conf b/V2Ray(B+G+A)+Nginx/nginx_real.conf new file mode 100644 index 00000000000..6beaebf337b --- /dev/null +++ b/V2Ray(B+G+A)+Nginx/nginx_real.conf @@ -0,0 +1,30 @@ +#ips-v4: +set_real_ip_from 103.21.244.0/22; +set_real_ip_from 103.22.200.0/22; +set_real_ip_from 103.31.4.0/22; +set_real_ip_from 104.16.0.0/13; +set_real_ip_from 104.24.0.0/14; +set_real_ip_from 108.162.192.0/18; +set_real_ip_from 131.0.72.0/22; +set_real_ip_from 141.101.64.0/18; +set_real_ip_from 162.158.0.0/15; +set_real_ip_from 172.64.0.0/13; +set_real_ip_from 173.245.48.0/20; +set_real_ip_from 188.114.96.0/20; +set_real_ip_from 190.93.240.0/20; +set_real_ip_from 197.234.240.0/22; +set_real_ip_from 198.41.128.0/17; +#ips-v6: +set_real_ip_from 2400:cb00::/32; +set_real_ip_from 2606:4700::/32; +set_real_ip_from 2803:f800::/32; +set_real_ip_from 2405:b500::/32; +set_real_ip_from 2405:8100::/32; +set_real_ip_from 2a06:98c0::/29; +set_real_ip_from 2c0f:f248::/32; +#real_ip_header CF-Connecting-IP; +real_ip_header X-Forwarded-For; +#ע +#1cloudflare ipsϢhttps://www.cloudflare.com/ipsʱ¡ +#2set_real_ip_fromӦIPΪֹãҪʵԶű㶨 +#3ʹCloudflare CDNԼset_real_ip_fromӦIP diff --git a/V2Ray(B+G+A)+Nginx/xray_SS-2022_config.json b/V2Ray(B+G+A)+Nginx/xray_SS-2022_config.json new file mode 100644 index 00000000000..87803a31d96 --- /dev/null +++ b/V2Ray(B+G+A)+Nginx/xray_SS-2022_config.json @@ -0,0 +1,46 @@ +//Shadowsocks-2022配置 +//原配置: +//........<省略>........ + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//以上配置修改为如下: +//单用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-chacha20-poly1305", //Shadowsocks-2022加密方法之一 + "password": "81qjRtwJZWx2gBphrLk18WZQ06B3Y2Vxlnqe903xXqU=", //修改为自己的密钥 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//多用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-aes-128-gcm", //Shadowsocks-2022加密方法之一 + "password": "rvQ6fK6Y4ckgFVslZlZUgQ==", //修改为自己的主项密钥 + "clients": [ + { + "password": "FPTg9fyNve167Fg8oPkFlQ==", //修改为自己的分项密钥 + "email": "2011@gmail.com" + }, + { + "password": "dkv04xu1f+UeM3mXpNJgVA==", //修改为自己的分项密钥 + "email": "2021@gmail.com" + } + ] + }, +//........<省略>........ +//备注: +//1、Xray从v1.5.9版开始支持Shadowsocks-2022。 +//2、密钥生成及长度 +//在服务器上直接使用‘openssl rand -base64 <长度> ’命令生成符合如下加密方法的对应密钥。 +// 加密方法 密钥长度 +//2022-blake3-aes-128-gcm 16 +//2022-blake3-aes-256-gcm 32 +//2022-blake3-chacha20-poly1305 32 +//3、多用户的客户端的密钥为主项密钥:分项密钥的组合,如rvQ6fK6Y4ckgFVslZlZUgQ==:FPTg9fyNve167Fg8oPkFlQ==。 diff --git a/V2Ray(Other Configuration)/1_SNI_config.json b/V2Ray(Other Configuration)/1_SNI_config.json new file mode 100644 index 00000000000..6e2f364baa4 --- /dev/null +++ b/V2Ray(Other Configuration)/1_SNI_config.json @@ -0,0 +1,48 @@ +//如下配置插入inbounds首位(全局参数) + { + "port": 443, //SNI分流应用的监听端口 + "protocol": "dokodemo-door", + "settings": { + "address": "0.0.0.0", + "network": "tcp", + "followRedirect": false + }, + "sniffing": { + "enabled": true, //开启流量探测 + "destOverride": [ + "tls" //tls探测,以实现SNI分流应用。 + ] + } + }, + +//如下配置插入routing首位(如下是两个域名示例,若多个就增加相关部分即可。)(各分项参数) + { + "type": "field", + "domain": [ + "zv.xx.yy" //修改成自己域名 + ], + "outboundTag": "zv" //与outbounds中标签对应 + }, + { + "type": "field", + "domain": [ + "zt.xx.yy" //修改成自己域名 + ], + "outboundTag": "zt" //与outbounds中标签对应 + }, + +//如下配置插入outbounds末尾标记blocked部分之前(如下是两个端口/域名示例,若多个就增加相关部分即可。)(各分项参数) + { + "tag": "zv", //标签,与routing中标签对应。 + "protocol": "freedom", + "settings": { + "redirect": "127.0.0.1:8443" //与应用的端口对应 + } + }, + { + "tag": "zt", //标签,与routing中标签对应。 + "protocol": "freedom", + "settings": { + "redirect": "127.0.0.1:6443" //与应用的端口对应 + } + }, diff --git a/V2Ray(Other Configuration)/2_SNI_config.json b/V2Ray(Other Configuration)/2_SNI_config.json new file mode 100644 index 00000000000..27e45023c5e --- /dev/null +++ b/V2Ray(Other Configuration)/2_SNI_config.json @@ -0,0 +1,54 @@ +//如下配置插入inbounds首位(全局参数) + { + "port": 443, //SNI分流应用的监听端口 + "protocol": "dokodemo-door", + "settings": { + "address": "0.0.0.0", + "network": "tcp", + "followRedirect": false + }, + "sniffing": { + "enabled": true, //开启流量探测 + "destOverride": [ + "tls" //tls探测,以实现SNI分流应用。 + ] + } + }, + +//如下配置插入routing首位(如下是两个域名示例,若多个就增加相关部分即可。)(各分项参数) + { + "type": "field", + "domain": [ + "zv.xx.yy" //修改成自己分流的域名 + ], + "outboundTag": "zv" //与outbounds中标签对应 + }, + { + "type": "field", + "domain": [ + "zt.xx.yy" //修改成自己分流的域名 + ], + "outboundTag": "zt" //与outbounds中标签对应 + }, + +//如下配置插入outbounds末尾标记blocked部分之前(如下是两个进程/域名示例,若多个就增加相关部分即可。)(各分项参数) + { + "tag": "zv", //标签,与routing中标签对应。 + "protocol": "freedom", + "streamSettings": { + "network": "domainsocket", + "dsSettings": { + "path": "/dev/shm/vless.sock" //与应用的进程对应 + } + } + }, + { + "tag": "zt", //标签,与routing中标签对应。 + "protocol": "freedom", + "streamSettings": { + "network": "domainsocket", + "dsSettings": { + "path": "/dev/shm/trojan.sock" //与应用的进程对应 + } + } + }, diff --git a/V2Ray(Other Configuration)/BT_config.json b/V2Ray(Other Configuration)/BT_config.json new file mode 100644 index 00000000000..efe96fcd42b --- /dev/null +++ b/V2Ray(Other Configuration)/BT_config.json @@ -0,0 +1,25 @@ +//在inbounds中为每个应用添加如下参数(若此应用需禁用BT)(单项参数) + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + +//如下配置插入routing末尾(全局参数) + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + +//如下配置插入outbounds末尾(全局参数) + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + diff --git a/V2Ray(Other Configuration)/README.md b/V2Ray(Other Configuration)/README.md new file mode 100644 index 00000000000..61c0c2f6c16 --- /dev/null +++ b/V2Ray(Other Configuration)/README.md @@ -0,0 +1,59 @@ +一、V2Ray 或 Xray 禁用 BT 的配置方法 + +见 BT_config.json 配置。 + +注意: + +1、仅服务端配置即可。 + +2、V2Ray 或 Xray 示例中各应用都配置了禁用 BT,此配置方法仅备份及参考。 + +二、V2Ray/Xray SNI 分流的配置方法 + +此方法也可以解决 V2Ray 或 Xray 应用与网站应用(原网站不想做回落网站,或 Nginx、Caddy 等有多个网站应用。)共用 443 端口问题。 + +注意: + +1、V2Ray/Xray SNI 分流不支持 PROXY protocol 发送。 + +2、1_SNI_config.json 采用 Local Loopback 连接,实现 V2Ray/Xray SNI 的端口分流。 + +3、2_SNI_config.json 采用 UDS 连接,实现 V2Ray/Xray SNI 的进程分流。 + +4、原 V2Ray/Xray SNI 分流示例已被其它 SNI 分流示例优势替代,此配置仅备份及参考等。 + +三、Xray fallbacks SNI 回落/分流到不同网站的配置方法 + +此方法解决 Xray 前置监听 443 后,不影响原来不同域名访问不同网站问题。见 fallbacks_SNI_config.json 配置。 + +注意: + +1、Xray 版本不小于 v1.2.2 才支持 VLESS fallbacks SNI shunt。Xray 版本不小于 v1.2.3 才支持 Trojan fallbacks SNI shunt。 + +2、若不同域名没有使用通配符证书,那么还需要在 Xray 中并列配置多个域名对应的证书及私钥。 + +3、此 fallbacks SNI 回落/分流是解除 TLS 后 Xray 进行的 name(域名)分流。 + +4、也可以用 Nginx SNI、Caddy 分流(SNI 分流 或 host 分流) 等分流来解决问题(不同方法,达到相同效果。),相关分流见各自配置示例。 + +四、V2Ray 或 Xray 流量统计的配置方法 + +1、配置流量统计(见 traffic_config.json 配置) + +1)、入站的流量统计(不推荐,一般建议关闭。),根据各个入站 tag 来记录。 + +2)、出站的流量统计(不推荐,一般建议关闭。),根据各个出站 tag 来记录。 + +3)、用户的流量统计(推荐),根据 email 来记录。SOCKS、HTTP 等其他协议内的用户不支持被统计。 + +2、流量统计处理 + +1)、把对应 traffic.sh(v2ray_traffic.sh 或 Xray_traffic.sh) 脚本上传到服务器 root 目录,并授予执行权限(chmod +x traffic.sh)。 + +2)、执行 ./traffic.sh 即可查看流量统计。 + +注意: + +1、开启流量统计需消耗服务器资源,严重时可能影响速度,非必要不需要配置。 + +2、采用 traffic.sh 脚本进行流量统计简单好用,但不支持重启及配置修改后保持之前记录,即重启及配置修改后记录归零。 diff --git a/V2Ray(Other Configuration)/Xray_traffic.sh b/V2Ray(Other Configuration)/Xray_traffic.sh new file mode 100644 index 00000000000..5d22ca87dad --- /dev/null +++ b/V2Ray(Other Configuration)/Xray_traffic.sh @@ -0,0 +1,52 @@ +#!/bin/bash + +_APISERVER=127.0.0.1:10085 //此端口必须与traffic_config.json中流量统计端口一致 +_XRAY=/usr/local/bin/xray/xray //此路径为Xray的实际路径 + +apidata () { + local ARGS= + if [[ $1 == "reset" ]]; then + ARGS="-reset=true" + fi + $_XRAY api statsquery --server=$_APISERVER "${ARGS}" \ + | awk '{ + if (match($1, /"name":/)) { + f=1; gsub(/^"|link"|,$/, "", $2); + split($2, p, ">>>"); + printf "%s:%s->%s\t", p[1],p[2],p[4]; + } + else if (match($1, /"value":/) && f){ + f = 0; + gsub(/"/, "", $2); + printf "%.0f\n", $2; + } + else if (match($0, /}/) && f) { f = 0; print 0; } + }' +} + +print_sum() { + local DATA="$1" + local PREFIX="$2" + local SORTED=$(echo "$DATA" | grep "^${PREFIX}" | sort -r) + local SUM=$(echo "$SORTED" | awk ' + /->up/{us+=$2} + /->down/{ds+=$2} + END{ + printf "SUM->up:\t%.0f\nSUM->down:\t%.0f\nSUM->TOTAL:\t%.0f\n", us, ds, us+ds; + }') + echo -e "${SORTED}\n${SUM}" \ + | numfmt --field=2 --suffix=B --to=iec \ + | column -t +} + +DATA=$(apidata $1) +echo "-----------Inbound-----------" //入站代理的流量统计(可根据traffic_config.json配置是否配置此部分参数) +print_sum "$DATA" "inbound" +echo "-----------------------------" +echo "-----------Outbound----------" //出站代理的流量统计(可根据traffic_config.json配置是否配置此部分参数) +print_sum "$DATA" "outbound" +echo "-----------------------------" +echo +echo "-------------User------------" //当前等级的所有用户的流量统计 +print_sum "$DATA" "user" +echo "-----------------------------" diff --git a/V2Ray(Other Configuration)/fallbacks_SNI_config.json b/V2Ray(Other Configuration)/fallbacks_SNI_config.json new file mode 100644 index 00000000000..bd7f6bf2f03 --- /dev/null +++ b/V2Ray(Other Configuration)/fallbacks_SNI_config.json @@ -0,0 +1,77 @@ +//一、与Caddy对应的Xray回落配置: +//常规配置(端口回落): +//........<省略>........ + "fallbacks": [ + { + "dest": 88, //h2与http/1.1回落端口(共用端口) + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。 + }, +//........<省略>........ + ] + +//修改常规配置如下:(示例仅配置了两个域名的分流;如需要多个域名,增加对应参数即可。) +//........<省略>........ + "fallbacks": [ + { + "name": "zv.xx.yy", //修改为自己分流的域名 + "dest": 818, //h2与http/1.1回落端口(共用端口) + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。 + }, + { + "name": "zt.xx.yy", //修改为自己分流的域名 + "dest": 828, //h2与http/1.1回落端口(共用端口) + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。 + }, +//........<省略>........ + ] +//备注: +//1、进程回落("dest"参数配置为进程)配置类似。 +//2、域名增加可能还需同步调整TLS证书,参考“CDN_v2ray_config.json”配置。 + + +//二、与Nginx对应的Xray回落配置: +//常规配置(端口回落): +//........<省略>........ + "fallbacks": [ + { + "alpn": "h2", //h2回落匹配 + "dest": 82, //h2回落端口 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + }, + { + "dest": 81, //http/1.1回落端口 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + }, +//........<省略>........ + ] + +//修改常规配置如下:(示例仅配置了两个域名的分流;如需要多个域名,增加对应参数即可。) +//........<省略>........ + "fallbacks": [ + { + "name": "zv.xx.yy", //修改为自己分流的域名 + "alpn": "h2", //h2回落匹配 + "dest": 812, //h2回落端口 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + }, + { + "name": "zv.xx.yy", //修改为自己分流的域名 + "dest": 811, //http/1.1回落端口 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + }, + { + "name": "zt.xx.yy", //修改为自己分流的域名 + "alpn": "h2", //h2回落匹配 + "dest": 822, //h2回落端口 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + }, + { + "name": "zt.xx.yy", //修改为自己分流的域名 + "dest": 821, //http/1.1回落端口 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + }, +//........<省略>........ + ] +//备注: +//1、进程回落("dest"参数配置为进程)配置类似。 +//2、域名增加可能还需同步调整TLS证书,参考“CDN_v2ray_config.json”配置。 diff --git a/V2Ray(Other Configuration)/traffic_config.json b/V2Ray(Other Configuration)/traffic_config.json new file mode 100644 index 00000000000..6eef7511052 --- /dev/null +++ b/V2Ray(Other Configuration)/traffic_config.json @@ -0,0 +1,66 @@ +//在配置中添加如下参数集(全局参数) + "stats": {}, //目前统计信息没有任何参数,只要此项存在,内部的统计开启。(开关) + "api": { + "tag": "api", + "services": [ + "StatsService" + ] + }, + "policy": { + "levels": { + "0": { //用户组等级标识,可以多个用户组。 + "statsUserUplink": true, //当值为true时,开启当前等级的所有用户的上行流量统计。 + "statsUserDownlink": true //当值为true时,开启当前等级的所有用户的下行流量统计。 + } + }, + "system": { + "statsInboundUplink": false, //当值为true时,开启所有入站代理的上行流量统计。建议不开启。 + "statsInboundDownlink": false, //当值为true时,开启所有入站代理的下行流量统计。建议不开启。 + "statsOutboundUplink": false, //当值为true时,开启所有出站代理的下行流量统计。建议不开启。 + "statsOutboundDownlink": false //当值为true时,开启所有出站代理的下行流量统计。建议不开启。 + } + }, + +//在inbounds中添加标识参数(针对各端口或进程、用户组等级归属与email标记)(各分项参数) + { + "tag": "VLESS-TCP-TLS", //此端口或进程的入站流量统计标识。如没开启入站流量统计,此参数可以不添加。 + "port": 443, + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "e731f153-4f31-49d3-9e8f-ff8f396135ef", + "level": 0, //用户组等级归属。默认0级组统计,此处可以省略。 + "email": "443@gmail.com" //用户组内流量统计标识。如要统计此用户,那么必须配置email,且不相同。 + } + ], +//........<省略>........ + } + } + +//如下配置插入inbounds末尾(全局参数) + { + "listen": "127.0.0.1", + "port": 10085, //此端口与Xray_traffic.sh或v2ray_traffic.sh中端口对应 + "protocol": "dokodemo-door", + "settings": { + "address": "127.0.0.1" + }, + "tag": "api" + } + +//如下配置插入routing的rules首位(注:如有v2ray SNI分流配置,那就插入它之后。)(全局参数) + { + "type": "field", + "inboundTag": [ + "api" + ], + "outboundTag": "api" + }, + +//在Outbounds中添加标识参数(针对协议或策略等)(各分项参数) + { + "tag": "out", //此协议或策略等的出站流量统计标识。如没开启出站流量统计,此参数可以不添加。 + "protocol": "freedom", + "settings": {} + }, diff --git a/V2Ray(Other Configuration)/v2ray_traffic.sh b/V2Ray(Other Configuration)/v2ray_traffic.sh new file mode 100644 index 00000000000..15e7bed0c46 --- /dev/null +++ b/V2Ray(Other Configuration)/v2ray_traffic.sh @@ -0,0 +1,48 @@ +#!/bin/bash + +_APISERVER=127.0.0.1:10085 //此端口必须与traffic_config.json中流量统计端口一致 +_V2CTL=/usr/local/bin/v2ray/v2ctl //此路径为V2Ray的v2ctl实际路径 + +apidata () { + local ARGS= + if [[ $1 == "reset" ]]; then + ARGS="reset: true" + fi + $_V2CTL api --server=$_APISERVER StatsService.QueryStats "${ARGS}" \ + | awk '{ + if (match($1, /name:/)) { + f=1; gsub(/^"|link"$/, "", $2); + split($2, p, ">>>"); + printf "%s:%s->%s\t", p[1],p[2],p[4]; + } + else if (match($1, /value:/) && f){ f = 0; printf "%.0f\n", $2; } + else if (match($0, /^>$/) && f) { f = 0; print 0; } + }' +} + +print_sum() { + local DATA="$1" + local PREFIX="$2" + local SORTED=$(echo "$DATA" | grep "^${PREFIX}" | sort -r) + local SUM=$(echo "$SORTED" | awk ' + /->up/{us+=$2} + /->down/{ds+=$2} + END{ + printf "SUM->up:\t%.0f\nSUM->down:\t%.0f\nSUM->TOTAL:\t%.0f\n", us, ds, us+ds; + }') + echo -e "${SORTED}\n${SUM}" \ + | numfmt --field=2 --suffix=B --to=iec \ + | column -t +} + +DATA=$(apidata $1) +echo "-----------Inbound-----------" //入站代理的流量统计(可根据traffic_config.json配置是否配置此部分参数) +print_sum "$DATA" "inbound" +echo "-----------------------------" +echo "-----------Outbound----------" //出站代理的流量统计(可根据traffic_config.json配置是否配置此部分参数) +print_sum "$DATA" "outbound" +echo "-----------------------------" +echo +echo "------------User-------------" //当前等级的所有用户的流量统计 +print_sum "$DATA" "user" +echo "-----------------------------" diff --git "a/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/Caddyfile" "b/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/Caddyfile" new file mode 100644 index 00000000000..343cfe7b7e0 --- /dev/null +++ "b/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/Caddyfile" @@ -0,0 +1,47 @@ +{ + order reverse_proxy before route + admin off + log { + output file /var/log/caddy/error.log + level ERROR + } #版本不小于v2.4.0才支持日志全局配置 + email your@email.com #修改为自己的电子邮箱(选配) + + servers :443 { + trusted_proxies cloudflare { #cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + interval 12h + timeout 15s + } #配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + protocols h1 h2 + } +} + +:443, xx.yy { #xx.yy修改为自己的域名。注意:逗号与域名之间有一个空格。 + tls { + ciphers TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + curves x25519 secp521r1 secp384r1 secp256r1 + alpn http/1.1 h2 + } + + @pws { + path /2ALdGZ9k #与Door+WebSocket应用中path对应 + header Connection *Upgrade* + header Upgrade websocket + } + reverse_proxy @pws 127.0.0.1:2002 #转发给本机Door+WebSocket监听端口 + + @host { + host xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + } + route @host { + header { + Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" #启用HSTS + } + file_server { + root /var/www/html #修改为自己存放的WEB文件路径 + } + } +} +#备注: +#1、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +#2、本示例目前仅推荐套CDN来避免被封。 diff --git "a/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/README.md" "b/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/README.md" new file mode 100644 index 00000000000..c924440d127 --- /dev/null +++ "b/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/README.md" @@ -0,0 +1,30 @@ +介绍: + +1、本示例配置采用 V2Ray 或 Xray 自带 Shadowsocks 应用加 Dokodemo-Door 的 WebSocket 应用(等同 v2ray-plugin 或 xray-plugin 插件的 websocket 模式,简记为 Door+WebSocket。) 组合,直接实现原版 Shadowsocks 加 v2ray-plugin 或 xray-plugin 插件的 websocket 模式服务端应用。 + +2、利用 Nginx 或 Caddy 支持 WebSocket 代理实现等同原版 Shadowsocks 加 v2ray-plugin 或 xray-plugin 插件的 websocket-tls 模式服务端应用,TLS 由 Nginx 启用及处理或由 Caddy 提供及处理。 + +原理: + +默认流程:WEB client <-------- HTTPS(HTTP/1.1+TLS) -------> Nginx/Caddy(WEB server) +反代流程:Shadowsocks client <------- WebSocket+TLS --------> Nginx/Caddy <-- WebSocket --> V2Ray/Xray server + +注意: + +1、SS 为 shadowsocks 简写。 + +2、V2Ray 或 Xray 的监听地址不支持 Dokodemo-Door 协议使用 UDS 监听。 + +3、v2ray_LLb_config.json 采用 Local Loopback 实现 Shadowsocks 应用与 Dokodemo-Door 的 WebSocket 应用连接,v2ray_UDS_config.json 采用 UDS 实现 Shadowsocks 应用与 Dokodemo-Door 的 WebSocket 应用连接;根据情况二选一即可。 + +4、本示例 Shadowsocks 加 v2ray-plugin 或 xray-plugin 插件的 websocket-tls 模式服务端应用不等同 V2Ray 或 Xray 的 Shadowsocks+WebSocket+TLS 应用,两者不兼容。 + +5、Nginx 支持 HTTPS server 及 WebSocket proxy 需要 Nginx 包含 http_ssl_module 模块及 OpenSSL 库。 + +6、Nginx 支持请求标头还原为真实客户端地址需要 Nginx 包含 http_realip_module 模块。 + +7、若采用 Nginx 反向代理,不要使用 ACME 客户端在采用本示例的服务器上以 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书,因 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书需监听 80 或 443 端口,从而与当前应用端口冲突。 + +8、若采用 Caddy 反向代理,本示例 Caddy 支持自动 HTTPS,即自动申请与更新 TLS 证书,自动 HTTP 重定向到 HTTPS。 + +9、配置1:使用 Local Loopback 连接。配置2:使用 UDS 连接。 diff --git "a/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/nginx.conf" "b/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/nginx.conf" new file mode 100644 index 00000000000..d1457d60c95 --- /dev/null +++ "b/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/nginx.conf" @@ -0,0 +1,75 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 443 ssl default_server; + listen [::]:443 ssl default_server; #无IPv6,此项可以删除。 + ssl_protocols TLSv1.2 TLSv1.3; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen 443 ssl; + listen [::]:443 ssl; #无IPv6,此项可以删除。 + include nginx_real.conf; #插入nginx_real.conf配置文件(real应用配置块,实现套CDN的应用的访问IP还原为客户端原始IP。选配,套CDN配置。) + server_name xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/xx.yy/xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/xx.yy/xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location = /2ALdGZ9k { #与Door+WebSocket应用中path对应 + if ($http_upgrade != "websocket") { + return 404; + } #WebSocket协商失败时返回404 + proxy_redirect off; + proxy_pass http://127.0.0.1:2002; #转发给本机Door+WebSocket监听端口 + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例目前仅推荐套CDN来避免被封。 diff --git "a/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/nginx_real.conf" "b/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/nginx_real.conf" new file mode 100644 index 00000000000..6beaebf337b --- /dev/null +++ "b/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/nginx_real.conf" @@ -0,0 +1,30 @@ +#ips-v4: +set_real_ip_from 103.21.244.0/22; +set_real_ip_from 103.22.200.0/22; +set_real_ip_from 103.31.4.0/22; +set_real_ip_from 104.16.0.0/13; +set_real_ip_from 104.24.0.0/14; +set_real_ip_from 108.162.192.0/18; +set_real_ip_from 131.0.72.0/22; +set_real_ip_from 141.101.64.0/18; +set_real_ip_from 162.158.0.0/15; +set_real_ip_from 172.64.0.0/13; +set_real_ip_from 173.245.48.0/20; +set_real_ip_from 188.114.96.0/20; +set_real_ip_from 190.93.240.0/20; +set_real_ip_from 197.234.240.0/22; +set_real_ip_from 198.41.128.0/17; +#ips-v6: +set_real_ip_from 2400:cb00::/32; +set_real_ip_from 2606:4700::/32; +set_real_ip_from 2803:f800::/32; +set_real_ip_from 2405:b500::/32; +set_real_ip_from 2405:8100::/32; +set_real_ip_from 2a06:98c0::/29; +set_real_ip_from 2c0f:f248::/32; +#real_ip_header CF-Connecting-IP; +real_ip_header X-Forwarded-For; +#ע +#1cloudflare ipsϢhttps://www.cloudflare.com/ipsʱ¡ +#2set_real_ip_fromӦIPΪֹãҪʵԶű㶨 +#3ʹCloudflare CDNԼset_real_ip_fromӦIP diff --git "a/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/v2ray_LLb_config.json" "b/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/v2ray_LLb_config.json" new file mode 100644 index 00000000000..1777eac4289 --- /dev/null +++ "b/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/v2ray_LLb_config.json" @@ -0,0 +1,80 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "tag": "ddws", //标签,与routing中标签对应。 + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2002, //Door+WebSocket监听端口 + "protocol": "dokodemo-door", + "settings": { + "address": "v1.mux.cool", + "network": "tcp", + "followRedirect": false + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/2ALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2003, //SS监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2003", //修改为自己的密码 + "email": "2003@gmail.com" + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "inboundTag": [ + "ddws" //与inbounds中标签对应 + ], + "outboundTag": "loopback" //与outbounds中标签对应 + }, + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "loopback", //标签,与routing中标签对应。 + "protocol": "freedom", + "settings": { + "redirect": "127.0.0.1:2003" //转发给本机SS监听端口 + } + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git "a/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/v2ray_UDS_config.json" "b/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/v2ray_UDS_config.json" new file mode 100644 index 00000000000..32a859e7bac --- /dev/null +++ "b/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/v2ray_UDS_config.json" @@ -0,0 +1,91 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "tag": "ddws", //标签,与routing中标签对应。 + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2002, //Door+WebSocket监听端口 + "protocol": "dokodemo-door", + "settings": { + "address": "v1.mux.cool", + "network": "tcp", + "followRedirect": false + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/2ALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2003, //使用UDS作为传输方式后此端口失效,但必须存在。 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2003", //修改为自己的密码 + "email": "2003@gmail.com" + }, + "streamSettings": { + "network": "domainsocket", + "security": "none", + "dsSettings": { + "path": "ssuds", //UDS文件路径,与outbounds中对应。 + "abstract": true //开启后不必考虑上面UDS文件绝对路径 + } + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "inboundTag": [ + "ddws" //与inbounds中标签对应 + ], + "outboundTag": "uds" //与outbounds中标签对应 + }, + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "uds", //标签,与routing中标签对应。 + "protocol": "freedom", + "streamSettings": { + "network": "domainsocket", + "dsSettings": { + "path": "ssuds", //UDS文件路径,与streamSettings中对应。 + "abstract": true //开启后不必考虑上面UDS文件绝对路径 + } + } + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git "a/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/xray_SS-2022_config.json" "b/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/xray_SS-2022_config.json" new file mode 100644 index 00000000000..57c442d5e8d --- /dev/null +++ "b/V2Ray(SS+Door+WebSocket)+Caddy\\Nginx/xray_SS-2022_config.json" @@ -0,0 +1,46 @@ +//Shadowsocks-2022配置 +//原配置: +//........<省略>........ + "settings": { + "method": "chacha20-poly1305", + "password": "diy2003", //修改为自己的密码 + "email": "2003@gmail.com" + }, +//........<省略>........ + +//以上配置修改为如下: +//单用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-chacha20-poly1305", //Shadowsocks-2022加密方法之一 + "password": "81qjRtwJZWx2gBphrLk18WZQ06B3Y2Vxlnqe903xXqU=", //修改为自己的密钥 + "email": "2003@gmail.com" + }, +//........<省略>........ + +//多用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-aes-128-gcm", //Shadowsocks-2022加密方法之一 + "password": "rvQ6fK6Y4ckgFVslZlZUgQ==", //修改为自己的主项密钥 + "clients": [ + { + "password": "FPTg9fyNve167Fg8oPkFlQ==", //修改为自己的分项密钥 + "email": "2003@gmail.com" + }, + { + "password": "dkv04xu1f+UeM3mXpNJgVA==", //修改为自己的分项密钥 + "email": "2013@gmail.com" + } + ] + }, +//........<省略>........ +//备注: +//1、Xray从v1.5.9版开始支持Shadowsocks-2022。 +//2、密钥生成及长度 +//在服务器上直接使用‘openssl rand -base64 <长度> ’命令生成符合如下加密方法的对应密钥。 +// 加密方法 密钥长度 +//2022-blake3-aes-128-gcm 16 +//2022-blake3-aes-256-gcm 32 +//2022-blake3-chacha20-poly1305 32 +//3、多用户的客户端的密钥为主项密钥:分项密钥的组合,如rvQ6fK6Y4ckgFVslZlZUgQ==:FPTg9fyNve167Fg8oPkFlQ==。 diff --git "a/V2Ray(SS+gRPC)+Caddy\\Nginx/README.md" "b/V2Ray(SS+gRPC)+Caddy\\Nginx/README.md" new file mode 100644 index 00000000000..28c88cddd25 --- /dev/null +++ "b/V2Ray(SS+gRPC)+Caddy\\Nginx/README.md" @@ -0,0 +1,30 @@ +介绍: + +利用 Nginx 或 Caddy 支持 gRPC 代理实现 V2Ray 或 Xray 的 Shadowsocks+gRPC+TLS 应用,TLS 由 Nginx 启用及处理或由 Caddy 提供及处理。 + +原理: + +默认流程:WEB client <------------ HTTP/2(H2C+TLS) ------------> Nginx/Caddy(WEB server) +反代流程:V2Ray/Xray client <-------------- gRPC+TLS --------------> Nginx/Caddy <-- gRPC --> V2Ray/Xray server + +注意: + +1、SS 为 shadowsocks 简写。 + +2、V2Ray 或 Xray 的监听地址不支持 Shadowsocks 协议使用 UDS 监听。 + +3、V2Ray 版本不小于 v4.36.2 或 Xray 版本不小于 v1.4.0 才支持 gRPC 传输方式。 + +4、Nginx 支持不同站点共用 443 端口需要 Nginx 包含 stream_core_module 和 stream_ssl_preread_module 模块。 + +5、Nginx 支持 HTTP/2 server 及 gRPC proxy 需要 Nginx 包含 http_ssl_module 与 http_v2_module 模块及 OpenSSL 库。 + +6、Nginx 支持请求标头还原为真实客户端地址需要 Nginx 包含 http_realip_module 模块。 + +7、若采用 Nginx 反向代理,不要使用 ACME 客户端在采用本示例的服务器上以 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书,因 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书需监听 80 或 443 端口,从而与当前应用端口冲突。 + +8、Caddy 版本不小于 v2.6.0 才支持 gRPC proxy 的 UDS 转发。 + +9、若采用 Caddy 反向代理,本示例 Caddy 支持自动 HTTPS,即自动申请与更新 TLS 证书,自动 HTTP 重定向到 HTTPS。 + +10、本示例兼容原版 Shadowsocks 加 v2ray-plugin 或 xray-plugin 插件的 grpc-tls 模式服务端应用,即客户端可使用 Shadowsocks 加 v2ray-plugin 或 xray-plugin 插件连接。 diff --git "a/V2Ray(SS+gRPC)+Caddy\\Nginx/caddy.json" "b/V2Ray(SS+gRPC)+Caddy\\Nginx/caddy.json" new file mode 100644 index 00000000000..4e3ed825d83 --- /dev/null +++ "b/V2Ray(SS+gRPC)+Caddy\\Nginx/caddy.json" @@ -0,0 +1,105 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "apps": { + "http": { + "servers": { + "https": { + "listen": [":443"], + "routes": [{ + "match": [{ + "protocol": "grpc", + "path": ["/SALdGZ9k/*"] //与Shadowsocks+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2011" //转发给本机Shadowsocks+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["z2.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2"] + } + } + }, + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//3、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 diff --git "a/V2Ray(SS+gRPC)+Caddy\\Nginx/nginx.conf" "b/V2Ray(SS+gRPC)+Caddy\\Nginx/nginx.conf" new file mode 100644 index 00000000000..177bca8e423 --- /dev/null +++ "b/V2Ray(SS+gRPC)+Caddy\\Nginx/nginx.conf" @@ -0,0 +1,110 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 443 ssl http2 default_server; + listen [::]:443 ssl http2 default_server; #无IPv6,此项可以删除。 + ssl_protocols TLSv1.2; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + server_name z1.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z1.xx.yy/z1.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z1.xx.yy/z1.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2; + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305; #非AES算法的密码套件。若证书为RSA证书,ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + include nginx_real.conf; #插入nginx_real.conf配置文件(real应用配置块,实现套CDN的应用的访问IP还原为客户端原始IP。选配,套CDN配置。) + server_name z2.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z2.xx.yy/z2.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z2.xx.yy/z2.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 diff --git "a/V2Ray(SS+gRPC)+Caddy\\Nginx/nginx_real.conf" "b/V2Ray(SS+gRPC)+Caddy\\Nginx/nginx_real.conf" new file mode 100644 index 00000000000..6beaebf337b --- /dev/null +++ "b/V2Ray(SS+gRPC)+Caddy\\Nginx/nginx_real.conf" @@ -0,0 +1,30 @@ +#ips-v4: +set_real_ip_from 103.21.244.0/22; +set_real_ip_from 103.22.200.0/22; +set_real_ip_from 103.31.4.0/22; +set_real_ip_from 104.16.0.0/13; +set_real_ip_from 104.24.0.0/14; +set_real_ip_from 108.162.192.0/18; +set_real_ip_from 131.0.72.0/22; +set_real_ip_from 141.101.64.0/18; +set_real_ip_from 162.158.0.0/15; +set_real_ip_from 172.64.0.0/13; +set_real_ip_from 173.245.48.0/20; +set_real_ip_from 188.114.96.0/20; +set_real_ip_from 190.93.240.0/20; +set_real_ip_from 197.234.240.0/22; +set_real_ip_from 198.41.128.0/17; +#ips-v6: +set_real_ip_from 2400:cb00::/32; +set_real_ip_from 2606:4700::/32; +set_real_ip_from 2803:f800::/32; +set_real_ip_from 2405:b500::/32; +set_real_ip_from 2405:8100::/32; +set_real_ip_from 2a06:98c0::/29; +set_real_ip_from 2c0f:f248::/32; +#real_ip_header CF-Connecting-IP; +real_ip_header X-Forwarded-For; +#ע +#1cloudflare ipsϢhttps://www.cloudflare.com/ipsʱ¡ +#2set_real_ip_fromӦIPΪֹãҪʵԶű㶨 +#3ʹCloudflare CDNԼset_real_ip_fromӦIP diff --git "a/V2Ray(SS+gRPC)+Caddy\\Nginx/v2ray_config.json" "b/V2Ray(SS+gRPC)+Caddy\\Nginx/v2ray_config.json" new file mode 100644 index 00000000000..d483a6b78ea --- /dev/null +++ "b/V2Ray(SS+gRPC)+Caddy\\Nginx/v2ray_config.json" @@ -0,0 +1,55 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git "a/V2Ray(SS+gRPC)+Caddy\\Nginx/xray_SS-2022_config.json" "b/V2Ray(SS+gRPC)+Caddy\\Nginx/xray_SS-2022_config.json" new file mode 100644 index 00000000000..87803a31d96 --- /dev/null +++ "b/V2Ray(SS+gRPC)+Caddy\\Nginx/xray_SS-2022_config.json" @@ -0,0 +1,46 @@ +//Shadowsocks-2022配置 +//原配置: +//........<省略>........ + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//以上配置修改为如下: +//单用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-chacha20-poly1305", //Shadowsocks-2022加密方法之一 + "password": "81qjRtwJZWx2gBphrLk18WZQ06B3Y2Vxlnqe903xXqU=", //修改为自己的密钥 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//多用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-aes-128-gcm", //Shadowsocks-2022加密方法之一 + "password": "rvQ6fK6Y4ckgFVslZlZUgQ==", //修改为自己的主项密钥 + "clients": [ + { + "password": "FPTg9fyNve167Fg8oPkFlQ==", //修改为自己的分项密钥 + "email": "2011@gmail.com" + }, + { + "password": "dkv04xu1f+UeM3mXpNJgVA==", //修改为自己的分项密钥 + "email": "2021@gmail.com" + } + ] + }, +//........<省略>........ +//备注: +//1、Xray从v1.5.9版开始支持Shadowsocks-2022。 +//2、密钥生成及长度 +//在服务器上直接使用‘openssl rand -base64 <长度> ’命令生成符合如下加密方法的对应密钥。 +// 加密方法 密钥长度 +//2022-blake3-aes-128-gcm 16 +//2022-blake3-aes-256-gcm 32 +//2022-blake3-chacha20-poly1305 32 +//3、多用户的客户端的密钥为主项密钥:分项密钥的组合,如rvQ6fK6Y4ckgFVslZlZUgQ==:FPTg9fyNve167Fg8oPkFlQ==。 diff --git a/V2Ray(Trojan+H2C)+Caddy/1_Caddyfile b/V2Ray(Trojan+H2C)+Caddy/1_Caddyfile new file mode 100644 index 00000000000..239810d5518 --- /dev/null +++ b/V2Ray(Trojan+H2C)+Caddy/1_Caddyfile @@ -0,0 +1,42 @@ +{ + order reverse_proxy before route + admin off + log { + output file /var/log/caddy/error.log + level ERROR + } #版本不小于v2.4.0才支持日志全局配置 + email your@email.com #修改为自己的电子邮箱(选配) + + servers :443 { + protocols h1 h2 #TLSv1.2不支持HTTP/3 server + } +} + +:443, xx.yy { #xx.yy修改为自己的域名。注意:逗号与域名之间有一个空格。 + tls { + protocols tls1.2 tls1.2 + ciphers TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 #非AES算法的密码套件 + curves secp521r1 secp384r1 secp256r1 + } + + reverse_proxy /teuW56Es 127.0.0.1:2006 { #与Trojan+H2C应用中path对应,转发给本机Trojan+H2C监听端口。 + transport http { + versions h2c 2 + } + } + + @host { + host xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + } + route @host { + header { + Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" #启用HSTS + } + file_server { + root /var/www/html #修改为自己存放的WEB文件路径 + } + } +} +#备注: +#1、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +#2、本配置使用非AES算法的密码套件配置来避免被封。 diff --git a/V2Ray(Trojan+H2C)+Caddy/1_v2ray_config.json b/V2Ray(Trojan+H2C)+Caddy/1_v2ray_config.json new file mode 100644 index 00000000000..8d357d533b1 --- /dev/null +++ b/V2Ray(Trojan+H2C)+Caddy/1_v2ray_config.json @@ -0,0 +1,58 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2006, //Trojan+H2C监听端口 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy2006", //修改为自己密码 + "email": "2006@gmail.com" + } + ] + }, + "streamSettings": { + "network": "h2", + "security": "none", + "httpSettings": { + "path": "/teuW56Es" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/V2Ray(Trojan+H2C)+Caddy/2_Caddyfile b/V2Ray(Trojan+H2C)+Caddy/2_Caddyfile new file mode 100644 index 00000000000..2b4264e2ae3 --- /dev/null +++ b/V2Ray(Trojan+H2C)+Caddy/2_Caddyfile @@ -0,0 +1,42 @@ +{ + order reverse_proxy before route + admin off + log { + output file /var/log/caddy/error.log + level ERROR + } #版本不小于v2.4.0才支持日志全局配置 + email your@email.com #修改为自己的电子邮箱(选配) + + servers :443 { + protocols h1 h2 #TLSv1.2不支持HTTP/3 server + } +} + +:443, xx.yy { #xx.yy修改为自己的域名。注意:逗号与域名之间有一个空格。 + tls { + protocols tls1.2 tls1.2 + ciphers TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 #非AES算法的密码套件 + curves secp521r1 secp384r1 secp256r1 + } + + reverse_proxy /teuW56Es unix/@trojanh2c { #与Trojan+H2C应用中path对应,转发给本机Trojan+H2C监听进程。 + transport http { + versions h2c 2 + } + } + + @host { + host xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + } + route @host { + header { + Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" #启用HSTS + } + file_server { + root /var/www/html #修改为自己存放的WEB文件路径 + } + } +} +#备注: +#1、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +#2、本配置使用非AES算法的密码套件配置来避免被封。 diff --git a/V2Ray(Trojan+H2C)+Caddy/2_v2ray_config.json b/V2Ray(Trojan+H2C)+Caddy/2_v2ray_config.json new file mode 100644 index 00000000000..fcca1f5785f --- /dev/null +++ b/V2Ray(Trojan+H2C)+Caddy/2_v2ray_config.json @@ -0,0 +1,57 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "@trojanh2c", //Trojan+H2C监听进程 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy2006", //修改为自己密码 + "email": "2006@gmail.com" + } + ] + }, + "streamSettings": { + "network": "h2", + "security": "none", + "httpSettings": { + "path": "/teuW56Es" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/V2Ray(Trojan+H2C)+Caddy/README.md b/V2Ray(Trojan+H2C)+Caddy/README.md new file mode 100644 index 00000000000..0a95cb3547e --- /dev/null +++ b/V2Ray(Trojan+H2C)+Caddy/README.md @@ -0,0 +1,18 @@ +介绍: + +利用 Caddy 支持 H2C 代理实现 V2Ray 或 Xray 的 Trojan+H2C+TLS 应用,TLS 由 Caddy 提供及处理。 + +原理: + +默认流程:WEB client <---------------- HTTP/2 -----------------> Caddy(WEB server) +反代流程:V2Ray/Xray client <----- HTTP/2(H2C+TLS) -----> Caddy <-- H2C --> V2Ray/Xray server + +注意: + +1、V2Ray 版本不小于 v4.31.0 才支持 Trojan 协议。 + +2、Caddy 版本不小于 v2.6.0 才支持 H2C proxy 的 UDS 转发。 + +3、本示例 Caddy 支持自动 HTTPS,即自动申请与更新 TLS 证书,自动 HTTP 重定向到 HTTPS。 + +4、配置1:使用 Local Loopback 连接。配置2:使用 UDS 连接。 diff --git "a/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/1_Caddyfile" "b/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/1_Caddyfile" new file mode 100644 index 00000000000..2e13b6572be --- /dev/null +++ "b/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/1_Caddyfile" @@ -0,0 +1,47 @@ +{ + order reverse_proxy before route + admin off + log { + output file /var/log/caddy/error.log + level ERROR + } #版本不小于v2.4.0才支持日志全局配置 + email your@email.com #修改为自己的电子邮箱(选配) + + servers :443 { + trusted_proxies cloudflare { #cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + interval 12h + timeout 15s + } #配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + protocols h1 h2 + } +} + +:443, xx.yy { #xx.yy修改为自己的域名。注意:逗号与域名之间有一个空格。 + tls { + ciphers TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + curves x25519 secp521r1 secp384r1 secp256r1 + alpn http/1.1 h2 + } + + @tws { + path /9ALdGZ9k #与Trojan+WebSocket应用中path对应 + header Connection *Upgrade* + header Upgrade websocket + } + reverse_proxy @tws 127.0.0.1:2007 #转发给本机Trojan+WebSocket监听端口 + + @host { + host xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + } + route @host { + header { + Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" #启用HSTS + } + file_server { + root /var/www/html #修改为自己存放的WEB文件路径 + } + } +} +#备注: +#1、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +#2、本示例目前仅推荐套CDN来避免被封。 diff --git "a/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/1_nginx.conf" "b/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/1_nginx.conf" new file mode 100644 index 00000000000..ca56299771d --- /dev/null +++ "b/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/1_nginx.conf" @@ -0,0 +1,75 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 443 ssl default_server; + listen [::]:443 ssl default_server; #无IPv6,此项可以删除。 + ssl_protocols TLSv1.2 TLSv1.3; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen 443 ssl; + listen [::]:443 ssl; #无IPv6,此项可以删除。 + include nginx_real.conf; #插入nginx_real.conf配置文件(real应用配置块,实现套CDN的应用的访问IP还原为客户端原始IP。选配,套CDN配置。) + server_name xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/xx.yy/xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/xx.yy/xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location = /9ALdGZ9k { #与Trojan+WebSocket应用中path对应 + if ($http_upgrade != "websocket") { + return 404; + } #WebSocket协商失败时返回404 + proxy_redirect off; + proxy_pass http://127.0.0.1:2007; #转发给本机Trojan+WebSocket监听端口 + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例目前仅推荐套CDN来避免被封。 diff --git "a/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/1_v2ray_config.json" "b/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/1_v2ray_config.json" new file mode 100644 index 00000000000..c450ce021da --- /dev/null +++ "b/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/1_v2ray_config.json" @@ -0,0 +1,58 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2007, //Trojan+WebSocket监听端口 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy2007", //修改为自己密码 + "email": "2007@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/9ALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git "a/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/2_Caddyfile" "b/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/2_Caddyfile" new file mode 100644 index 00000000000..fa2fb0412c9 --- /dev/null +++ "b/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/2_Caddyfile" @@ -0,0 +1,47 @@ +{ + order reverse_proxy before route + admin off + log { + output file /var/log/caddy/error.log + level ERROR + } #版本不小于v2.4.0才支持日志全局配置 + email your@email.com #修改为自己的电子邮箱(选配) + + servers :443 { + trusted_proxies cloudflare { #cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + interval 12h + timeout 15s + } #配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + protocols h1 h2 + } +} + +:443, xx.yy { #xx.yy修改为自己的域名。注意:逗号与域名之间有一个空格。 + tls { + ciphers TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + curves x25519 secp521r1 secp384r1 secp256r1 + alpn http/1.1 h2 + } + + @tws { + path /9ALdGZ9k #与Trojan+WebSocket应用中path对应 + header Connection *Upgrade* + header Upgrade websocket + } + reverse_proxy @tws unix/@trojanws #转发给本机Trojan+WebSocket监听进程 + + @host { + host xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + } + route @host { + header { + Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" #启用HSTS + } + file_server { + root /var/www/html #修改为自己存放的WEB文件路径 + } + } +} +#备注: +#1、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +#2、本示例目前仅推荐套CDN来避免被封。 diff --git "a/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/2_nginx.conf" "b/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/2_nginx.conf" new file mode 100644 index 00000000000..065e390261c --- /dev/null +++ "b/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/2_nginx.conf" @@ -0,0 +1,75 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 443 ssl default_server; + listen [::]:443 ssl default_server; #无IPv6,此项可以删除。 + ssl_protocols TLSv1.2 TLSv1.3; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen 443 ssl; + listen [::]:443 ssl; #无IPv6,此项可以删除。 + include nginx_real.conf; #插入nginx_real.conf配置文件(real应用配置块,实现套CDN的应用的访问IP还原为客户端原始IP。选配,套CDN配置。) + server_name xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/xx.yy/xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/xx.yy/xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location = /9ALdGZ9k { #与Trojan+WebSocket应用中path对应 + if ($http_upgrade != "websocket") { + return 404; + } #WebSocket协商失败时返回404 + proxy_redirect off; + proxy_pass http://unix:/dev/shm/tws.sock; #转发给本机Trojan+WebSocket监听进程 + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例目前仅推荐套CDN来避免被封。 diff --git "a/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/2_v2ray_config.json" "b/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/2_v2ray_config.json" new file mode 100644 index 00000000000..ad8ea02498d --- /dev/null +++ "b/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/2_v2ray_config.json" @@ -0,0 +1,57 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "/dev/shm/trojanws.sock", //Trojan+WebSocket监听进程。若采用Caddy反向代理,/dev/shm/trojanws.sock修改为@trojanws。 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy2007", //修改为自己密码 + "email": "2007@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/9ALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git "a/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/README.md" "b/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/README.md" new file mode 100644 index 00000000000..c909a3b453b --- /dev/null +++ "b/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/README.md" @@ -0,0 +1,24 @@ +介绍: + +利用 Nginx 或 Caddy 支持 WebSocket 代理实现 V2Ray 或 Xray 的 Trojan+WebSocket+TLS 应用,TLS 由 Nginx 启用及处理或由 Caddy 提供及处理。 + +原理: + +默认流程:WEB client <------------ HTTPS(HTTP/1.1+TLS) ------------> Nginx/Caddy(WEB server) +反代流程:V2Ray/Xray client <------------- WebSocket+TLS -------------> Nginx/Caddy <-- WebSocket --> V2Ray/Xray server + +注意: + +1、V2Ray 版本不小于 v4.31.0 才支持 Trojan 协议。 + +2、Nginx 支持 HTTPS server 及 WebSocket proxy 需要 Nginx 包含 http_ssl_module 模块及 OpenSSL 库。 + +3、Nginx 支持请求标头还原为真实客户端地址需要 Nginx 包含 http_realip_module 模块。 + +4、若采用 Nginx 反向代理,不要使用 ACME 客户端在采用本示例的服务器上以 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书,因 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书需监听 80 或 443 端口,从而与当前应用端口冲突。 + +5、若采用 Caddy 反向代理,本示例 Caddy 支持自动 HTTPS,即自动申请与更新 TLS 证书,自动 HTTP 重定向到 HTTPS。 + +6、配置1:使用 Local Loopback 连接。配置2:使用 UDS 连接。 + +7、本示例兼容原版 Trojan-Go 的服务端 WebSocket 应用,即可使用 Trojan-Go 客户端连接(多路复用不能启用,不兼容。)。 diff --git "a/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/nginx_real.conf" "b/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/nginx_real.conf" new file mode 100644 index 00000000000..6beaebf337b --- /dev/null +++ "b/V2Ray(Trojan+WebSocket)+Caddy\\Nginx/nginx_real.conf" @@ -0,0 +1,30 @@ +#ips-v4: +set_real_ip_from 103.21.244.0/22; +set_real_ip_from 103.22.200.0/22; +set_real_ip_from 103.31.4.0/22; +set_real_ip_from 104.16.0.0/13; +set_real_ip_from 104.24.0.0/14; +set_real_ip_from 108.162.192.0/18; +set_real_ip_from 131.0.72.0/22; +set_real_ip_from 141.101.64.0/18; +set_real_ip_from 162.158.0.0/15; +set_real_ip_from 172.64.0.0/13; +set_real_ip_from 173.245.48.0/20; +set_real_ip_from 188.114.96.0/20; +set_real_ip_from 190.93.240.0/20; +set_real_ip_from 197.234.240.0/22; +set_real_ip_from 198.41.128.0/17; +#ips-v6: +set_real_ip_from 2400:cb00::/32; +set_real_ip_from 2606:4700::/32; +set_real_ip_from 2803:f800::/32; +set_real_ip_from 2405:b500::/32; +set_real_ip_from 2405:8100::/32; +set_real_ip_from 2a06:98c0::/29; +set_real_ip_from 2c0f:f248::/32; +#real_ip_header CF-Connecting-IP; +real_ip_header X-Forwarded-For; +#ע +#1cloudflare ipsϢhttps://www.cloudflare.com/ipsʱ¡ +#2set_real_ip_fromӦIPΪֹãҪʵԶű㶨 +#3ʹCloudflare CDNԼset_real_ip_fromӦIP diff --git "a/V2Ray(Trojan+gRPC)+Caddy\\Nginx/1_caddy.json" "b/V2Ray(Trojan+gRPC)+Caddy\\Nginx/1_caddy.json" new file mode 100644 index 00000000000..ccde764eede --- /dev/null +++ "b/V2Ray(Trojan+gRPC)+Caddy\\Nginx/1_caddy.json" @@ -0,0 +1,105 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "apps": { + "http": { + "servers": { + "https": { + "listen": [":443"], + "routes": [{ + "match": [{ + "protocol": "grpc", + "path": ["/TALdGZ9k/*"] //与Trojan+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2010" //转发给本机Trojan+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["z2.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2"] + } + } + }, + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//3、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 diff --git "a/V2Ray(Trojan+gRPC)+Caddy\\Nginx/1_nginx.conf" "b/V2Ray(Trojan+gRPC)+Caddy\\Nginx/1_nginx.conf" new file mode 100644 index 00000000000..1229331c2c2 --- /dev/null +++ "b/V2Ray(Trojan+gRPC)+Caddy\\Nginx/1_nginx.conf" @@ -0,0 +1,110 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 443 ssl http2 default_server; + listen [::]:443 ssl http2 default_server; #无IPv6,此项可以删除。 + ssl_protocols TLSv1.2; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + server_name z1.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z1.xx.yy/z1.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z1.xx.yy/z1.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2; + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305; #非AES算法的密码套件。若证书为RSA证书,ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location /TALdGZ9k { #与Trojan+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2010; #转发给本机Trojan+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + include nginx_real.conf; #插入nginx_real.conf配置文件(real应用配置块,实现套CDN的应用的访问IP还原为客户端原始IP。选配,套CDN配置。) + server_name z2.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z2.xx.yy/z2.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z2.xx.yy/z2.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location /TALdGZ9k { #与Trojan+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2010; #转发给本机Trojan+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 diff --git "a/V2Ray(Trojan+gRPC)+Caddy\\Nginx/1_v2ray_config.json" "b/V2Ray(Trojan+gRPC)+Caddy\\Nginx/1_v2ray_config.json" new file mode 100644 index 00000000000..af7719b05dd --- /dev/null +++ "b/V2Ray(Trojan+gRPC)+Caddy\\Nginx/1_v2ray_config.json" @@ -0,0 +1,58 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2010, //Trojan+gRPC监听端口 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy2010", //修改为自己密码 + "email": "2010@gmail.com" + } + ] + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "TALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git "a/V2Ray(Trojan+gRPC)+Caddy\\Nginx/2_caddy.json" "b/V2Ray(Trojan+gRPC)+Caddy\\Nginx/2_caddy.json" new file mode 100644 index 00000000000..e6d721960c2 --- /dev/null +++ "b/V2Ray(Trojan+gRPC)+Caddy\\Nginx/2_caddy.json" @@ -0,0 +1,105 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "apps": { + "http": { + "servers": { + "https": { + "listen": [":443"], + "routes": [{ + "match": [{ + "protocol": "grpc", + "path": ["/TALdGZ9k/*"] //与Trojan+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "unix/@trojangrpc" //转发给本机Trojan+gRPC监听进程 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["z2.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2"] + } + } + }, + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//3、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 diff --git "a/V2Ray(Trojan+gRPC)+Caddy\\Nginx/2_nginx.conf" "b/V2Ray(Trojan+gRPC)+Caddy\\Nginx/2_nginx.conf" new file mode 100644 index 00000000000..d803e524692 --- /dev/null +++ "b/V2Ray(Trojan+gRPC)+Caddy\\Nginx/2_nginx.conf" @@ -0,0 +1,110 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 443 ssl http2 default_server; + listen [::]:443 ssl http2 default_server; #无IPv6,此项可以删除。 + ssl_protocols TLSv1.2; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + server_name z1.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z1.xx.yy/z1.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z1.xx.yy/z1.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2; + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305; #非AES算法的密码套件。若证书为RSA证书,ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location /TALdGZ9k { #与Trojan+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://unix:/dev/shm/tgrpc.sock; #转发给本机Trojan+gRPC监听进程 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + include nginx_real.conf; #插入nginx_real.conf配置文件(real应用配置块,实现套CDN的应用的访问IP还原为客户端原始IP。选配,套CDN配置。) + server_name z2.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z2.xx.yy/z2.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z2.xx.yy/z2.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location /TALdGZ9k { #与Trojan+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://unix:/dev/shm/tgrpc.sock; #转发给本机Trojan+gRPC监听进程 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 diff --git "a/V2Ray(Trojan+gRPC)+Caddy\\Nginx/2_v2ray_config.json" "b/V2Ray(Trojan+gRPC)+Caddy\\Nginx/2_v2ray_config.json" new file mode 100644 index 00000000000..22189bbfdd7 --- /dev/null +++ "b/V2Ray(Trojan+gRPC)+Caddy\\Nginx/2_v2ray_config.json" @@ -0,0 +1,57 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "/dev/shm/trojangrpc.sock", //Trojan+gRPC监听进程。若采用Caddy反向代理,/dev/shm/trojangrpc.sock修改为@trojangrpc。 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy2010", //修改为自己密码 + "email": "2010@gmail.com" + } + ] + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "TALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git "a/V2Ray(Trojan+gRPC)+Caddy\\Nginx/README.md" "b/V2Ray(Trojan+gRPC)+Caddy\\Nginx/README.md" new file mode 100644 index 00000000000..19ce4990721 --- /dev/null +++ "b/V2Ray(Trojan+gRPC)+Caddy\\Nginx/README.md" @@ -0,0 +1,26 @@ +介绍: + +利用 Nginx 或 Caddy 支持 gRPC 代理实现 V2Ray 或 Xray 的 Trojan+gRPC+TLS 应用,TLS 由 Nginx 启用及处理或由 Caddy 提供及处理。 + +原理: + +默认流程:WEB client <------ HTTP/2(H2C+TLS) ------> Nginx/Caddy(WEB server) +反代流程:V2Ray/Xray client <-------- gRPC+TLS --------> Nginx/Caddy <-- gRPC --> V2Ray/Xray server + +注意: + +1、V2Ray 版本不小于 v4.36.2 或 Xray 版本不小于 v1.4.0 才支持 gRPC 传输方式。 + +2、Nginx 支持不同站点共用 443 端口需要 Nginx 包含 stream_core_module 和 stream_ssl_preread_module 模块。 + +3、Nginx 支持 HTTP/2 server 及 gRPC proxy 需要 Nginx 包含 http_ssl_module 与 http_v2_module 模块及 OpenSSL 库。 + +4、Nginx 支持请求标头还原为真实客户端地址需要 Nginx 包含 http_realip_module 模块。 + +5、若采用 Nginx 反向代理,不要使用 ACME 客户端在采用本示例的服务器上以 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书,因 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书需监听 80 或 443 端口,从而与当前应用端口冲突。 + +6、Caddy 版本不小于 v2.6.0 才支持 gRPC proxy 的 UDS 转发。 + +7、若采用 Caddy 反向代理,本示例 Caddy 支持自动 HTTPS,即自动申请与更新 TLS 证书,自动 HTTP 重定向到 HTTPS。 + +8、配置1:使用 Local Loopback 连接。配置2:使用 UDS 连接。 diff --git "a/V2Ray(Trojan+gRPC)+Caddy\\Nginx/nginx_real.conf" "b/V2Ray(Trojan+gRPC)+Caddy\\Nginx/nginx_real.conf" new file mode 100644 index 00000000000..6beaebf337b --- /dev/null +++ "b/V2Ray(Trojan+gRPC)+Caddy\\Nginx/nginx_real.conf" @@ -0,0 +1,30 @@ +#ips-v4: +set_real_ip_from 103.21.244.0/22; +set_real_ip_from 103.22.200.0/22; +set_real_ip_from 103.31.4.0/22; +set_real_ip_from 104.16.0.0/13; +set_real_ip_from 104.24.0.0/14; +set_real_ip_from 108.162.192.0/18; +set_real_ip_from 131.0.72.0/22; +set_real_ip_from 141.101.64.0/18; +set_real_ip_from 162.158.0.0/15; +set_real_ip_from 172.64.0.0/13; +set_real_ip_from 173.245.48.0/20; +set_real_ip_from 188.114.96.0/20; +set_real_ip_from 190.93.240.0/20; +set_real_ip_from 197.234.240.0/22; +set_real_ip_from 198.41.128.0/17; +#ips-v6: +set_real_ip_from 2400:cb00::/32; +set_real_ip_from 2606:4700::/32; +set_real_ip_from 2803:f800::/32; +set_real_ip_from 2405:b500::/32; +set_real_ip_from 2405:8100::/32; +set_real_ip_from 2a06:98c0::/29; +set_real_ip_from 2c0f:f248::/32; +#real_ip_header CF-Connecting-IP; +real_ip_header X-Forwarded-For; +#ע +#1cloudflare ipsϢhttps://www.cloudflare.com/ipsʱ¡ +#2set_real_ip_fromӦIPΪֹãҪʵԶű㶨 +#3ʹCloudflare CDNԼset_real_ip_fromӦIP diff --git a/V2Ray(VLESS+H2C)+Caddy/1_Caddyfile b/V2Ray(VLESS+H2C)+Caddy/1_Caddyfile new file mode 100644 index 00000000000..398cfc21643 --- /dev/null +++ b/V2Ray(VLESS+H2C)+Caddy/1_Caddyfile @@ -0,0 +1,42 @@ +{ + order reverse_proxy before route + admin off + log { + output file /var/log/caddy/error.log + level ERROR + } #版本不小于v2.4.0才支持日志全局配置 + email your@email.com #修改为自己的电子邮箱(选配) + + servers :443 { + protocols h1 h2 #TLSv1.2不支持HTTP/3 server + } +} + +:443, xx.yy { #xx.yy修改为自己的域名。注意:逗号与域名之间有一个空格。 + tls { + protocols tls1.2 tls1.2 + ciphers TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 #非AES算法的密码套件 + curves secp521r1 secp384r1 secp256r1 + } + + reverse_proxy /SeuW56Es 127.0.0.1:2005 { #与VLESS+H2C应用中path对应,转发给本机VLESS+H2C监听端口。 + transport http { + versions h2c 2 + } + } + + @host { + host xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + } + route @host { + header { + Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" #启用HSTS + } + file_server { + root /var/www/html #修改为自己存放的WEB文件路径 + } + } +} +#备注: +#1、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +#2、本配置使用非AES算法的密码套件配置来避免被封。 diff --git a/V2Ray(VLESS+H2C)+Caddy/1_v2ray_config.json b/V2Ray(VLESS+H2C)+Caddy/1_v2ray_config.json new file mode 100644 index 00000000000..6b5852d342f --- /dev/null +++ b/V2Ray(VLESS+H2C)+Caddy/1_v2ray_config.json @@ -0,0 +1,59 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2005, //VLESS+H2C监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "httpSettings": { + "path": "/SeuW56Es" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/V2Ray(VLESS+H2C)+Caddy/2_Caddyfile b/V2Ray(VLESS+H2C)+Caddy/2_Caddyfile new file mode 100644 index 00000000000..269cb72a52c --- /dev/null +++ b/V2Ray(VLESS+H2C)+Caddy/2_Caddyfile @@ -0,0 +1,42 @@ +{ + order reverse_proxy before route + admin off + log { + output file /var/log/caddy/error.log + level ERROR + } #版本不小于v2.4.0才支持日志全局配置 + email your@email.com #修改为自己的电子邮箱(选配) + + servers :443 { + protocols h1 h2 #TLSv1.2不支持HTTP/3 server + } +} + +:443, xx.yy { #xx.yy修改为自己的域名。注意:逗号与域名之间有一个空格。 + tls { + protocols tls1.2 tls1.2 + ciphers TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 #非AES算法的密码套件 + curves secp521r1 secp384r1 secp256r1 + } + + reverse_proxy /SeuW56Es unix/@vlessh2c { #与VLESS+H2C应用中path对应,转发给本机VLESS+H2C监听进程。 + transport http { + versions h2c 2 + } + } + + @host { + host xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + } + route @host { + header { + Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" #启用HSTS + } + file_server { + root /var/www/html #修改为自己存放的WEB文件路径 + } + } +} +#备注: +#1、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +#2、本配置使用非AES算法的密码套件配置来避免被封。 diff --git a/V2Ray(VLESS+H2C)+Caddy/2_v2ray_config.json b/V2Ray(VLESS+H2C)+Caddy/2_v2ray_config.json new file mode 100644 index 00000000000..a57a710950c --- /dev/null +++ b/V2Ray(VLESS+H2C)+Caddy/2_v2ray_config.json @@ -0,0 +1,58 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "@vlessh2c", //VLESS+H2C监听进程 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "httpSettings": { + "path": "/SeuW56Es" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/V2Ray(VLESS+H2C)+Caddy/README.md b/V2Ray(VLESS+H2C)+Caddy/README.md new file mode 100644 index 00000000000..a2bff257612 --- /dev/null +++ b/V2Ray(VLESS+H2C)+Caddy/README.md @@ -0,0 +1,16 @@ +介绍: + +利用 Caddy 支持 H2C 代理实现 V2Ray 或 Xray 的 VLESS+H2C+TLS 应用,TLS 由 Caddy 提供及处理。 + +原理: + +默认流程:WEB client <---------------- HTTP/2 -----------------> Caddy(WEB server) +反代流程:V2Ray/Xray client <----- HTTP/2(H2C+TLS) -----> Caddy <-- H2C --> V2Ray/Xray server + +注意: + +1、Caddy 版本不小于 v2.6.0 才支持 H2C proxy 的 UDS 转发。 + +2、本示例 Caddy 支持自动 HTTPS,即自动申请与更新 TLS 证书,自动 HTTP 重定向到 HTTPS。 + +3、配置1:使用 Local Loopback 连接。配置2:使用 UDS 连接。 diff --git "a/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/1_Caddyfile" "b/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/1_Caddyfile" new file mode 100644 index 00000000000..e9058fee55b --- /dev/null +++ "b/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/1_Caddyfile" @@ -0,0 +1,47 @@ +{ + order reverse_proxy before route + admin off + log { + output file /var/log/caddy/error.log + level ERROR + } #版本不小于v2.4.0才支持日志全局配置 + email your@email.com #修改为自己的电子邮箱(选配) + + servers :443 { + trusted_proxies cloudflare { #cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + interval 12h + timeout 15s + } #配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + protocols h1 h2 + } +} + +:443, xx.yy { #xx.yy修改为自己的域名。注意:逗号与域名之间有一个空格。 + tls { + ciphers TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + curves x25519 secp521r1 secp384r1 secp256r1 + alpn http/1.1 h2 + } + + @vlws { + path /WqLdGZ9k #与VLESS+WebSocket应用中path对应 + header Connection *Upgrade* + header Upgrade websocket + } + reverse_proxy @vlws 127.0.0.1:2012 #转发给本机VLESS+WebSocket监听端口 + + @host { + host xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + } + route @host { + header { + Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" #启用HSTS + } + file_server { + root /var/www/html #修改为自己存放的WEB文件路径 + } + } +} +#备注: +#1、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +#2、本示例目前仅推荐套CDN来避免被封。 diff --git "a/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/1_nginx.conf" "b/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/1_nginx.conf" new file mode 100644 index 00000000000..d162a1cd4e2 --- /dev/null +++ "b/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/1_nginx.conf" @@ -0,0 +1,75 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 443 ssl default_server; + listen [::]:443 ssl default_server; #无IPv6,此项可以删除。 + ssl_protocols TLSv1.2 TLSv1.3; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen 443 ssl; + listen [::]:443 ssl; #无IPv6,此项可以删除。 + include nginx_real.conf; #插入nginx_real.conf配置文件(real应用配置块,实现套CDN的应用的访问IP还原为客户端原始IP。选配,套CDN配置。) + server_name xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/xx.yy/xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/xx.yy/xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location = /WqLdGZ9k { #与VLESS+WebSocket应用中path对应 + if ($http_upgrade != "websocket") { + return 404; + } #WebSocket协商失败时返回404 + proxy_redirect off; + proxy_pass http://127.0.0.1:2012; #转发给本机VLESS+WebSocket监听端口 + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例目前仅推荐套CDN来避免被封。 diff --git "a/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/1_v2ray_config.json" "b/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/1_v2ray_config.json" new file mode 100644 index 00000000000..dee76ca7630 --- /dev/null +++ "b/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/1_v2ray_config.json" @@ -0,0 +1,59 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2012, //VLESS+WebSocket监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2012@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/WqLdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git "a/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/2_Caddyfile" "b/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/2_Caddyfile" new file mode 100644 index 00000000000..0c5af52a7fd --- /dev/null +++ "b/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/2_Caddyfile" @@ -0,0 +1,47 @@ +{ + order reverse_proxy before route + admin off + log { + output file /var/log/caddy/error.log + level ERROR + } #版本不小于v2.4.0才支持日志全局配置 + email your@email.com #修改为自己的电子邮箱(选配) + + servers :443 { + trusted_proxies cloudflare { #cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + interval 12h + timeout 15s + } #配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + protocols h1 h2 + } +} + +:443, xx.yy { #xx.yy修改为自己的域名。注意:逗号与域名之间有一个空格。 + tls { + ciphers TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + curves x25519 secp521r1 secp384r1 secp256r1 + alpn http/1.1 h2 + } + + @vlws { + path /WqLdGZ9k #与VLESS+WebSocket应用中path对应 + header Connection *Upgrade* + header Upgrade websocket + } + reverse_proxy @vlws unix/@vlessws #转发给本机VLESS+WebSocket监听进程 + + @host { + host xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + } + route @host { + header { + Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" #启用HSTS + } + file_server { + root /var/www/html #修改为自己存放的WEB文件路径 + } + } +} +#备注: +#1、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +#2、本示例目前仅推荐套CDN来避免被封。 diff --git "a/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/2_nginx.conf" "b/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/2_nginx.conf" new file mode 100644 index 00000000000..0a7551d7080 --- /dev/null +++ "b/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/2_nginx.conf" @@ -0,0 +1,75 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 443 ssl default_server; + listen [::]:443 ssl default_server; #无IPv6,此项可以删除。 + ssl_protocols TLSv1.2 TLSv1.3; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen 443 ssl; + listen [::]:443 ssl; #无IPv6,此项可以删除。 + include nginx_real.conf; #插入nginx_real.conf配置文件(real应用配置块,实现套CDN的应用的访问IP还原为客户端原始IP。选配,套CDN配置。) + server_name xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/xx.yy/xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/xx.yy/xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location = /WqLdGZ9k { #与VLESS+WebSocket应用中path对应 + if ($http_upgrade != "websocket") { + return 404; + } #WebSocket协商失败时返回404 + proxy_redirect off; + proxy_pass http://unix:/dev/shm/vlessws.sock; #转发给本机VLESS+WebSocket监听进程 + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例目前仅推荐套CDN来避免被封。 diff --git "a/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/2_v2ray_config.json" "b/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/2_v2ray_config.json" new file mode 100644 index 00000000000..9d318fa1077 --- /dev/null +++ "b/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/2_v2ray_config.json" @@ -0,0 +1,58 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "/dev/shm/vlessws.sock", //VLESS+WebSocket监听进程。若采用Caddy反向代理,/dev/shm/vlessws.sock修改为@vlessws。 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2012@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/WqLdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git "a/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/README.md" "b/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/README.md" new file mode 100644 index 00000000000..d7f9bb593e3 --- /dev/null +++ "b/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/README.md" @@ -0,0 +1,20 @@ +介绍: + +利用 Nginx 或 Caddy 支持 WebSocket 代理实现 V2Ray 或 Xray 的 VLESS+WebSocket+TLS 应用,TLS 由 Nginx 启用及处理或由 Caddy 提供及处理。 + +原理: + +默认流程:WEB client <------ HTTPS(HTTP/1.1+TLS) ------> Nginx/Caddy(WEB server) +反代流程:V2Ray/Xray client <------- WebSocket+TLS -------> Nginx/Caddy <-- WebSocket --> V2Ray/Xray server + +注意: + +1、Nginx 支持 HTTPS server 及 WebSocket proxy 需要 Nginx 包含 http_ssl_module 模块及 OpenSSL 库。 + +2、Nginx 支持请求标头还原为真实客户端地址需要 Nginx 包含 http_realip_module 模块。 + +3、若采用 Nginx 反向代理,不要使用 ACME 客户端在采用本示例的服务器上以 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书,因 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书需监听 80 或 443 端口,从而与当前应用端口冲突。 + +4、若采用 Caddy 反向代理,本示例 Caddy 支持自动 HTTPS,即自动申请与更新 TLS 证书,自动 HTTP 重定向到 HTTPS。 + +5、配置1:使用 Local Loopback 连接。配置2:使用 UDS 连接。 diff --git "a/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/nginx_real.conf" "b/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/nginx_real.conf" new file mode 100644 index 00000000000..6beaebf337b --- /dev/null +++ "b/V2Ray(VLESS+WebSocket)+Caddy\\Nginx/nginx_real.conf" @@ -0,0 +1,30 @@ +#ips-v4: +set_real_ip_from 103.21.244.0/22; +set_real_ip_from 103.22.200.0/22; +set_real_ip_from 103.31.4.0/22; +set_real_ip_from 104.16.0.0/13; +set_real_ip_from 104.24.0.0/14; +set_real_ip_from 108.162.192.0/18; +set_real_ip_from 131.0.72.0/22; +set_real_ip_from 141.101.64.0/18; +set_real_ip_from 162.158.0.0/15; +set_real_ip_from 172.64.0.0/13; +set_real_ip_from 173.245.48.0/20; +set_real_ip_from 188.114.96.0/20; +set_real_ip_from 190.93.240.0/20; +set_real_ip_from 197.234.240.0/22; +set_real_ip_from 198.41.128.0/17; +#ips-v6: +set_real_ip_from 2400:cb00::/32; +set_real_ip_from 2606:4700::/32; +set_real_ip_from 2803:f800::/32; +set_real_ip_from 2405:b500::/32; +set_real_ip_from 2405:8100::/32; +set_real_ip_from 2a06:98c0::/29; +set_real_ip_from 2c0f:f248::/32; +#real_ip_header CF-Connecting-IP; +real_ip_header X-Forwarded-For; +#ע +#1cloudflare ipsϢhttps://www.cloudflare.com/ipsʱ¡ +#2set_real_ip_fromӦIPΪֹãҪʵԶű㶨 +#3ʹCloudflare CDNԼset_real_ip_fromӦIP diff --git "a/V2Ray(VLESS+gRPC)+Caddy\\Nginx/1_caddy.json" "b/V2Ray(VLESS+gRPC)+Caddy\\Nginx/1_caddy.json" new file mode 100644 index 00000000000..ccc7880617a --- /dev/null +++ "b/V2Ray(VLESS+gRPC)+Caddy\\Nginx/1_caddy.json" @@ -0,0 +1,105 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "apps": { + "http": { + "servers": { + "https": { + "listen": [":443"], + "routes": [{ + "match": [{ + "protocol": "grpc", + "path": ["/VRLdGZ9k/*"] //与VLESS+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2013" //转发给本机VLESS+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["z2.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2"] + } + } + }, + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//3、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 diff --git "a/V2Ray(VLESS+gRPC)+Caddy\\Nginx/1_nginx.conf" "b/V2Ray(VLESS+gRPC)+Caddy\\Nginx/1_nginx.conf" new file mode 100644 index 00000000000..06278c80541 --- /dev/null +++ "b/V2Ray(VLESS+gRPC)+Caddy\\Nginx/1_nginx.conf" @@ -0,0 +1,110 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 443 ssl http2 default_server; + listen [::]:443 ssl http2 default_server; #无IPv6,此项可以删除。 + ssl_protocols TLSv1.2; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + server_name z1.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z1.xx.yy/z1.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z1.xx.yy/z1.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2; + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305; #非AES算法的密码套件。若证书为RSA证书,ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location /VRLdGZ9k { #与VLESS+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2013; #转发给本机VLESS+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + include nginx_real.conf; #插入nginx_real.conf配置文件(real应用配置块,实现套CDN的应用的访问IP还原为客户端原始IP。选配,套CDN配置。) + server_name z2.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z2.xx.yy/z2.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z2.xx.yy/z2.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location /VRLdGZ9k { #与VLESS+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2013; #转发给本机VLESS+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 diff --git "a/V2Ray(VLESS+gRPC)+Caddy\\Nginx/1_v2ray_config.json" "b/V2Ray(VLESS+gRPC)+Caddy\\Nginx/1_v2ray_config.json" new file mode 100644 index 00000000000..26c5cec93a3 --- /dev/null +++ "b/V2Ray(VLESS+gRPC)+Caddy\\Nginx/1_v2ray_config.json" @@ -0,0 +1,59 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2013, //VLESS+gRPC监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "058e0bf3-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2013@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "VRLdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git "a/V2Ray(VLESS+gRPC)+Caddy\\Nginx/2_caddy.json" "b/V2Ray(VLESS+gRPC)+Caddy\\Nginx/2_caddy.json" new file mode 100644 index 00000000000..c0d0ec716ea --- /dev/null +++ "b/V2Ray(VLESS+gRPC)+Caddy\\Nginx/2_caddy.json" @@ -0,0 +1,105 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "apps": { + "http": { + "servers": { + "https": { + "listen": [":443"], + "routes": [{ + "match": [{ + "protocol": "grpc", + "path": ["/VALdGZ9k/*"] //与VLESS+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "unix/@vlessgrpc" //转发给本机VLESS+gRPC监听进程 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["z2.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2"] + } + } + }, + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//3、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 diff --git "a/V2Ray(VLESS+gRPC)+Caddy\\Nginx/2_nginx.conf" "b/V2Ray(VLESS+gRPC)+Caddy\\Nginx/2_nginx.conf" new file mode 100644 index 00000000000..1534589dbfc --- /dev/null +++ "b/V2Ray(VLESS+gRPC)+Caddy\\Nginx/2_nginx.conf" @@ -0,0 +1,110 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 443 ssl http2 default_server; + listen [::]:443 ssl http2 default_server; #无IPv6,此项可以删除。 + ssl_protocols TLSv1.2; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + server_name z1.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z1.xx.yy/z1.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z1.xx.yy/z1.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2; + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305; #非AES算法的密码套件。若证书为RSA证书,ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location /VRLdGZ9k { #与VLESS+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://unix:/dev/shm/vlessgrpc.sock; #转发给本机VLESS+gRPC监听进程 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + include nginx_real.conf; #插入nginx_real.conf配置文件(real应用配置块,实现套CDN的应用的访问IP还原为客户端原始IP。选配,套CDN配置。) + server_name z2.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z2.xx.yy/z2.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z2.xx.yy/z2.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location /VRLdGZ9k { #与VLESS+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://unix:/dev/shm/vlessgrpc.sock; #转发给本机VLESS+gRPC监听进程 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 diff --git "a/V2Ray(VLESS+gRPC)+Caddy\\Nginx/2_v2ray_config.json" "b/V2Ray(VLESS+gRPC)+Caddy\\Nginx/2_v2ray_config.json" new file mode 100644 index 00000000000..809e0d36a3d --- /dev/null +++ "b/V2Ray(VLESS+gRPC)+Caddy\\Nginx/2_v2ray_config.json" @@ -0,0 +1,58 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "/dev/shm/vlessgrpc.sock", //VLESS+gRPC监听进程。若采用Caddy反向代理,/dev/shm/vlessgrpc.sock修改为@vlessgrpc。 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "058e0bf3-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2013@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "VRLdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git "a/V2Ray(VLESS+gRPC)+Caddy\\Nginx/README.md" "b/V2Ray(VLESS+gRPC)+Caddy\\Nginx/README.md" new file mode 100644 index 00000000000..b37f1cdf707 --- /dev/null +++ "b/V2Ray(VLESS+gRPC)+Caddy\\Nginx/README.md" @@ -0,0 +1,26 @@ +介绍: + +利用 Nginx 或 Caddy 支持 gRPC 代理实现 V2Ray 或 Xray 的 VLESS+gRPC+TLS 应用,TLS 由 Nginx 启用及处理或由 Caddy 提供及处理。 + +原理: + +默认流程:WEB client <------ HTTP/2(H2C+TLS) ------> Nginx/Caddy(WEB server) +反代流程:V2Ray/Xray client <-------- gRPC+TLS --------> Nginx/Caddy <-- gRPC --> V2Ray/Xray server + +注意: + +1、V2Ray 版本不小于 v4.36.2 或 Xray 版本不小于 v1.4.0 才支持 gRPC 传输方式。 + +2、Nginx 支持不同站点共用 443 端口需要 Nginx 包含 stream_core_module 和 stream_ssl_preread_module 模块。 + +3、Nginx 支持 HTTP/2 server 及 gRPC proxy 需要 Nginx 包含 http_ssl_module 与 http_v2_module 模块及 OpenSSL 库。 + +4、Nginx 支持请求标头还原为真实客户端地址需要 Nginx 包含 http_realip_module 模块。 + +5、若采用 Nginx 反向代理,不要使用 ACME 客户端在采用本示例的服务器上以 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书,因 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书需监听 80 或 443 端口,从而与当前应用端口冲突。 + +6、Caddy 版本不小于 v2.6.0 才支持 gRPC proxy 的 UDS 转发。 + +7、若采用 Caddy 反向代理,本示例 Caddy 支持自动 HTTPS,即自动申请与更新 TLS 证书,自动 HTTP 重定向到 HTTPS。 + +8、配置1:使用 Local Loopback 连接。配置2:使用 UDS 连接。 diff --git "a/V2Ray(VLESS+gRPC)+Caddy\\Nginx/nginx_real.conf" "b/V2Ray(VLESS+gRPC)+Caddy\\Nginx/nginx_real.conf" new file mode 100644 index 00000000000..6beaebf337b --- /dev/null +++ "b/V2Ray(VLESS+gRPC)+Caddy\\Nginx/nginx_real.conf" @@ -0,0 +1,30 @@ +#ips-v4: +set_real_ip_from 103.21.244.0/22; +set_real_ip_from 103.22.200.0/22; +set_real_ip_from 103.31.4.0/22; +set_real_ip_from 104.16.0.0/13; +set_real_ip_from 104.24.0.0/14; +set_real_ip_from 108.162.192.0/18; +set_real_ip_from 131.0.72.0/22; +set_real_ip_from 141.101.64.0/18; +set_real_ip_from 162.158.0.0/15; +set_real_ip_from 172.64.0.0/13; +set_real_ip_from 173.245.48.0/20; +set_real_ip_from 188.114.96.0/20; +set_real_ip_from 190.93.240.0/20; +set_real_ip_from 197.234.240.0/22; +set_real_ip_from 198.41.128.0/17; +#ips-v6: +set_real_ip_from 2400:cb00::/32; +set_real_ip_from 2606:4700::/32; +set_real_ip_from 2803:f800::/32; +set_real_ip_from 2405:b500::/32; +set_real_ip_from 2405:8100::/32; +set_real_ip_from 2a06:98c0::/29; +set_real_ip_from 2c0f:f248::/32; +#real_ip_header CF-Connecting-IP; +real_ip_header X-Forwarded-For; +#ע +#1cloudflare ipsϢhttps://www.cloudflare.com/ipsʱ¡ +#2set_real_ip_fromӦIPΪֹãҪʵԶű㶨 +#3ʹCloudflare CDNԼset_real_ip_fromӦIP diff --git "a/V2Ray(VLESS\\VMess+mKCP+seed)/README.md" "b/V2Ray(VLESS\\VMess+mKCP+seed)/README.md" new file mode 100644 index 00000000000..a91a471e375 --- /dev/null +++ "b/V2Ray(VLESS\\VMess+mKCP+seed)/README.md" @@ -0,0 +1,3 @@ +介绍: + +本示例为 V2Ray 或 Xray 的 mKCP 配置,包括 VLESS+mKCP+seed 与 VMess+mKCP+seed 两种应用。若网络差,推荐部署。 diff --git "a/V2Ray(VLESS\\VMess+mKCP+seed)/v2ray_vless_config.json" "b/V2Ray(VLESS\\VMess+mKCP+seed)/v2ray_vless_config.json" new file mode 100644 index 00000000000..74ace4fcfd3 --- /dev/null +++ "b/V2Ray(VLESS\\VMess+mKCP+seed)/v2ray_vless_config.json" @@ -0,0 +1,61 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用v2ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用v2ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git "a/V2Ray(VLESS\\VMess+mKCP+seed)/v2ray_vmess_config.json" "b/V2Ray(VLESS\\VMess+mKCP+seed)/v2ray_vmess_config.json" new file mode 100644 index 00000000000..8fd9e266467 --- /dev/null +++ "b/V2Ray(VLESS\\VMess+mKCP+seed)/v2ray_vmess_config.json" @@ -0,0 +1,60 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用v2ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用v2ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "port": 2052, //监听端口 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ] + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git "a/V2Ray(VMess+WebSocket)+Caddy\\Nginx/1_Caddyfile" "b/V2Ray(VMess+WebSocket)+Caddy\\Nginx/1_Caddyfile" new file mode 100644 index 00000000000..b625a502779 --- /dev/null +++ "b/V2Ray(VMess+WebSocket)+Caddy\\Nginx/1_Caddyfile" @@ -0,0 +1,47 @@ +{ + order reverse_proxy before route + admin off + log { + output file /var/log/caddy/error.log + level ERROR + } #版本不小于v2.4.0才支持日志全局配置 + email your@email.com #修改为自己的电子邮箱(选配) + + servers :443 { + trusted_proxies cloudflare { #cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + interval 12h + timeout 15s + } #配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + protocols h1 h2 + } +} + +:443, xx.yy { #xx.yy修改为自己的域名。注意:逗号与域名之间有一个空格。 + tls { + ciphers TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + curves x25519 secp521r1 secp384r1 secp256r1 + alpn http/1.1 h2 + } + + @vmws { + path /HALdGZ9k #与VMess+WebSocket应用中path对应 + header Connection *Upgrade* + header Upgrade websocket + } + reverse_proxy @vmws 127.0.0.1:2001 #转发给本机VMess+WebSocket监听端口 + + @host { + host xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + } + route @host { + header { + Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" #启用HSTS + } + file_server { + root /var/www/html #修改为自己存放的WEB文件路径 + } + } +} +#备注: +#1、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +#2、本示例目前仅推荐套CDN来避免被封。 diff --git "a/V2Ray(VMess+WebSocket)+Caddy\\Nginx/1_nginx.conf" "b/V2Ray(VMess+WebSocket)+Caddy\\Nginx/1_nginx.conf" new file mode 100644 index 00000000000..4e3bf0560be --- /dev/null +++ "b/V2Ray(VMess+WebSocket)+Caddy\\Nginx/1_nginx.conf" @@ -0,0 +1,75 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 443 ssl default_server; + listen [::]:443 ssl default_server; #无IPv6,此项可以删除。 + ssl_protocols TLSv1.2 TLSv1.3; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen 443 ssl; + listen [::]:443 ssl; #无IPv6,此项可以删除。 + include nginx_real.conf; #插入nginx_real.conf配置文件(real应用配置块,实现套CDN的应用的访问IP还原为客户端原始IP。选配,套CDN配置。) + server_name xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/xx.yy/xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/xx.yy/xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location = /HALdGZ9k { #与VMess+WebSocket应用中path对应 + if ($http_upgrade != "websocket") { + return 404; + } #WebSocket协商失败时返回404 + proxy_redirect off; + proxy_pass http://127.0.0.1:2001; #转发给本机VMess+WebSocket监听端口 + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例目前仅推荐套CDN来避免被封。 diff --git "a/V2Ray(VMess+WebSocket)+Caddy\\Nginx/1_v2ray_config.json" "b/V2Ray(VMess+WebSocket)+Caddy\\Nginx/1_v2ray_config.json" new file mode 100644 index 00000000000..5da09edcbc5 --- /dev/null +++ "b/V2Ray(VMess+WebSocket)+Caddy\\Nginx/1_v2ray_config.json" @@ -0,0 +1,58 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2001, //VMess+WebSocket监听端口 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git "a/V2Ray(VMess+WebSocket)+Caddy\\Nginx/2_Caddyfile" "b/V2Ray(VMess+WebSocket)+Caddy\\Nginx/2_Caddyfile" new file mode 100644 index 00000000000..16cd455d7ec --- /dev/null +++ "b/V2Ray(VMess+WebSocket)+Caddy\\Nginx/2_Caddyfile" @@ -0,0 +1,47 @@ +{ + order reverse_proxy before route + admin off + log { + output file /var/log/caddy/error.log + level ERROR + } #版本不小于v2.4.0才支持日志全局配置 + email your@email.com #修改为自己的电子邮箱(选配) + + servers :443 { + trusted_proxies cloudflare { #cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + interval 12h + timeout 15s + } #配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + protocols h1 h2 + } +} + +:443, xx.yy { #xx.yy修改为自己的域名。注意:逗号与域名之间有一个空格。 + tls { + ciphers TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256 TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384 TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256 + curves x25519 secp521r1 secp384r1 secp256r1 + alpn http/1.1 h2 + } + + @vmws { + path /HALdGZ9k #与VMess+WebSocket应用中path对应 + header Connection *Upgrade* + header Upgrade websocket + } + reverse_proxy @vmws unix/@vmessws #转发给本机VMess+WebSocket监听进程 + + @host { + host xx.yy #限定域名访问(禁止以IP方式访问网站),修改为自己的域名。 + } + route @host { + header { + Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" #启用HSTS + } + file_server { + root /var/www/html #修改为自己存放的WEB文件路径 + } + } +} +#备注: +#1、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +#2、本示例目前仅推荐套CDN来避免被封。 diff --git "a/V2Ray(VMess+WebSocket)+Caddy\\Nginx/2_nginx.conf" "b/V2Ray(VMess+WebSocket)+Caddy\\Nginx/2_nginx.conf" new file mode 100644 index 00000000000..6e1f7a8f217 --- /dev/null +++ "b/V2Ray(VMess+WebSocket)+Caddy\\Nginx/2_nginx.conf" @@ -0,0 +1,75 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 443 ssl default_server; + listen [::]:443 ssl default_server; #无IPv6,此项可以删除。 + ssl_protocols TLSv1.2 TLSv1.3; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen 443 ssl; + listen [::]:443 ssl; #无IPv6,此项可以删除。 + include nginx_real.conf; #插入nginx_real.conf配置文件(real应用配置块,实现套CDN的应用的访问IP还原为客户端原始IP。选配,套CDN配置。) + server_name xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/xx.yy/xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/xx.yy/xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location = /HALdGZ9k { #与VMess+WebSocket应用中path对应 + if ($http_upgrade != "websocket") { + return 404; + } #WebSocket协商失败时返回404 + proxy_redirect off; + proxy_pass http://unix:/dev/shm/vmessws.sock; #转发给本机VMess+WebSocket监听进程 + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例目前仅推荐套CDN来避免被封。 diff --git "a/V2Ray(VMess+WebSocket)+Caddy\\Nginx/2_v2ray_config.json" "b/V2Ray(VMess+WebSocket)+Caddy\\Nginx/2_v2ray_config.json" new file mode 100644 index 00000000000..50aca35cc24 --- /dev/null +++ "b/V2Ray(VMess+WebSocket)+Caddy\\Nginx/2_v2ray_config.json" @@ -0,0 +1,57 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "/dev/shm/vmessws.sock", //VMess+WebSocket监听进程。若采用Caddy反向代理,/dev/shm/vmessws.sock修改为@vmessws。 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git "a/V2Ray(VMess+WebSocket)+Caddy\\Nginx/README.md" "b/V2Ray(VMess+WebSocket)+Caddy\\Nginx/README.md" new file mode 100644 index 00000000000..c9ab350281c --- /dev/null +++ "b/V2Ray(VMess+WebSocket)+Caddy\\Nginx/README.md" @@ -0,0 +1,20 @@ +介绍: + +利用 Nginx 或 Caddy 支持 WebSocket 代理实现 V2Ray 或 Xray 的 VMess+WebSocket+TLS 应用,TLS 由 Nginx 启用及处理或由 Caddy 提供及处理。 + +原理: + +默认流程:WEB client <------ HTTPS(HTTP/1.1+TLS) ------> Nginx/Caddy(WEB server) +反代流程:V2Ray/Xray client <------- WebSocket+TLS -------> Nginx/Caddy <-- WebSocket --> V2Ray/Xray server + +注意: + +1、Nginx 支持 HTTPS server 及 WebSocket proxy 需要 Nginx 包含 http_ssl_module 模块及 OpenSSL 库。 + +2、Nginx 支持请求标头还原为真实客户端地址需要 Nginx 包含 http_realip_module 模块。 + +3、若采用 Nginx 反向代理,不要使用 ACME 客户端在采用本示例的服务器上以 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书,因 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书需监听 80 或 443 端口,从而与当前应用端口冲突。 + +4、若采用 Caddy 反向代理,本示例 Caddy 支持自动 HTTPS,即自动申请与更新 TLS 证书,自动 HTTP 重定向到 HTTPS。 + +5、配置1:使用 Local Loopback 连接。配置2:使用 UDS 连接。 diff --git "a/V2Ray(VMess+WebSocket)+Caddy\\Nginx/nginx_real.conf" "b/V2Ray(VMess+WebSocket)+Caddy\\Nginx/nginx_real.conf" new file mode 100644 index 00000000000..6beaebf337b --- /dev/null +++ "b/V2Ray(VMess+WebSocket)+Caddy\\Nginx/nginx_real.conf" @@ -0,0 +1,30 @@ +#ips-v4: +set_real_ip_from 103.21.244.0/22; +set_real_ip_from 103.22.200.0/22; +set_real_ip_from 103.31.4.0/22; +set_real_ip_from 104.16.0.0/13; +set_real_ip_from 104.24.0.0/14; +set_real_ip_from 108.162.192.0/18; +set_real_ip_from 131.0.72.0/22; +set_real_ip_from 141.101.64.0/18; +set_real_ip_from 162.158.0.0/15; +set_real_ip_from 172.64.0.0/13; +set_real_ip_from 173.245.48.0/20; +set_real_ip_from 188.114.96.0/20; +set_real_ip_from 190.93.240.0/20; +set_real_ip_from 197.234.240.0/22; +set_real_ip_from 198.41.128.0/17; +#ips-v6: +set_real_ip_from 2400:cb00::/32; +set_real_ip_from 2606:4700::/32; +set_real_ip_from 2803:f800::/32; +set_real_ip_from 2405:b500::/32; +set_real_ip_from 2405:8100::/32; +set_real_ip_from 2a06:98c0::/29; +set_real_ip_from 2c0f:f248::/32; +#real_ip_header CF-Connecting-IP; +real_ip_header X-Forwarded-For; +#ע +#1cloudflare ipsϢhttps://www.cloudflare.com/ipsʱ¡ +#2set_real_ip_fromӦIPΪֹãҪʵԶű㶨 +#3ʹCloudflare CDNԼset_real_ip_fromӦIP diff --git "a/V2Ray(VMess+gRPC)+Caddy\\Nginx/1_caddy.json" "b/V2Ray(VMess+gRPC)+Caddy\\Nginx/1_caddy.json" new file mode 100644 index 00000000000..3a093bb1cb2 --- /dev/null +++ "b/V2Ray(VMess+gRPC)+Caddy\\Nginx/1_caddy.json" @@ -0,0 +1,105 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "apps": { + "http": { + "servers": { + "https": { + "listen": [":443"], + "routes": [{ + "match": [{ + "protocol": "grpc", + "path": ["/VALdGZ9k/*"] //与VMess+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2009" //转发给本机VMess+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["z2.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2"] + } + } + }, + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//3、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 diff --git "a/V2Ray(VMess+gRPC)+Caddy\\Nginx/1_nginx.conf" "b/V2Ray(VMess+gRPC)+Caddy\\Nginx/1_nginx.conf" new file mode 100644 index 00000000000..1e617f81e5c --- /dev/null +++ "b/V2Ray(VMess+gRPC)+Caddy\\Nginx/1_nginx.conf" @@ -0,0 +1,110 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 443 ssl http2 default_server; + listen [::]:443 ssl http2 default_server; #无IPv6,此项可以删除。 + ssl_protocols TLSv1.2; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + server_name z1.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z1.xx.yy/z1.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z1.xx.yy/z1.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2; + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305; #非AES算法的密码套件。若证书为RSA证书,ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location /VALdGZ9k { #与VMess+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2009; #转发给本机VMess+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + include nginx_real.conf; #插入nginx_real.conf配置文件(real应用配置块,实现套CDN的应用的访问IP还原为客户端原始IP。选配,套CDN配置。) + server_name z2.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z2.xx.yy/z2.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z2.xx.yy/z2.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location /VALdGZ9k { #与VMess+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2009; #转发给本机VMess+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 diff --git "a/V2Ray(VMess+gRPC)+Caddy\\Nginx/1_v2ray_config.json" "b/V2Ray(VMess+gRPC)+Caddy\\Nginx/1_v2ray_config.json" new file mode 100644 index 00000000000..5c208c8c898 --- /dev/null +++ "b/V2Ray(VMess+gRPC)+Caddy\\Nginx/1_v2ray_config.json" @@ -0,0 +1,58 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2009, //VMess+gRPC监听端口 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "058e0bf3-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2009@gmail.com" + } + ] + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "VALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git "a/V2Ray(VMess+gRPC)+Caddy\\Nginx/2_caddy.json" "b/V2Ray(VMess+gRPC)+Caddy\\Nginx/2_caddy.json" new file mode 100644 index 00000000000..920834518b1 --- /dev/null +++ "b/V2Ray(VMess+gRPC)+Caddy\\Nginx/2_caddy.json" @@ -0,0 +1,105 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "apps": { + "http": { + "servers": { + "https": { + "listen": [":443"], + "routes": [{ + "match": [{ + "protocol": "grpc", + "path": ["/VALdGZ9k/*"] //与VMess+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "unix/@vmessgrpc" //转发给本机VMess+gRPC监听进程 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["z2.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2"] + } + } + }, + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//3、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 diff --git "a/V2Ray(VMess+gRPC)+Caddy\\Nginx/2_nginx.conf" "b/V2Ray(VMess+gRPC)+Caddy\\Nginx/2_nginx.conf" new file mode 100644 index 00000000000..715c4a52aa9 --- /dev/null +++ "b/V2Ray(VMess+gRPC)+Caddy\\Nginx/2_nginx.conf" @@ -0,0 +1,110 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 443 ssl http2 default_server; + listen [::]:443 ssl http2 default_server; #无IPv6,此项可以删除。 + ssl_protocols TLSv1.2; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + server_name z1.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z1.xx.yy/z1.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z1.xx.yy/z1.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2; + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305; #非AES算法的密码套件。若证书为RSA证书,ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location /VALdGZ9k { #与VMess+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://unix:/dev/shm/vmessgrpc.sock; #转发给本机VMess+gRPC监听进程 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen 443 ssl http2; + listen [::]:443 ssl http2; #无IPv6,此项可以删除。 + include nginx_real.conf; #插入nginx_real.conf配置文件(real应用配置块,实现套CDN的应用的访问IP还原为客户端原始IP。选配,套CDN配置。) + server_name z2.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/z2.xx.yy/z2.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/z2.xx.yy/z2.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location /VALdGZ9k { #与VMess+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://unix:/dev/shm/vmessgrpc.sock; #转发给本机VMess+gRPC监听进程 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例使用非AES算法的密码套件配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 diff --git "a/V2Ray(VMess+gRPC)+Caddy\\Nginx/2_v2ray_config.json" "b/V2Ray(VMess+gRPC)+Caddy\\Nginx/2_v2ray_config.json" new file mode 100644 index 00000000000..63d85931392 --- /dev/null +++ "b/V2Ray(VMess+gRPC)+Caddy\\Nginx/2_v2ray_config.json" @@ -0,0 +1,57 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", //若使用V2Ray,此处目录名称xray改成v2ray。 + "access": "/var/log/xray/access.log" //若使用V2Ray,此处目录名称xray改成v2ray。 + }, + "inbounds": [ + { + "listen": "/dev/shm/vmessgrpc.sock", //VMess+gRPC监听进程。若采用Caddy反向代理,/dev/shm/vmessgrpc.sock修改为@vmessgrpc。 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "058e0bf3-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2009@gmail.com" + } + ] + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "VALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git "a/V2Ray(VMess+gRPC)+Caddy\\Nginx/README.md" "b/V2Ray(VMess+gRPC)+Caddy\\Nginx/README.md" new file mode 100644 index 00000000000..592c521fcc8 --- /dev/null +++ "b/V2Ray(VMess+gRPC)+Caddy\\Nginx/README.md" @@ -0,0 +1,26 @@ +介绍: + +利用 Nginx 或 Caddy 支持 gRPC 代理实现 V2Ray 或 Xray 的 VMess+gRPC+TLS 应用,TLS 由 Nginx 启用及处理或由 Caddy 提供及处理。 + +原理: + +默认流程:WEB client <------ HTTP/2(H2C+TLS) ------> Nginx/Caddy(WEB server) +反代流程:V2Ray/Xray client <-------- gRPC+TLS --------> Nginx/Caddy <-- gRPC --> V2Ray/Xray server + +注意: + +1、V2Ray 版本不小于 v4.36.2 或 Xray 版本不小于 v1.4.0 才支持 gRPC 传输方式。 + +2、Nginx 支持不同站点共用 443 端口需要 Nginx 包含 stream_core_module 和 stream_ssl_preread_module 模块。 + +3、Nginx 支持 HTTP/2 server 及 gRPC proxy 需要 Nginx 包含 http_ssl_module 与 http_v2_module 模块及 OpenSSL 库。 + +4、Nginx 支持请求标头还原为真实客户端地址需要 Nginx 包含 http_realip_module 模块。 + +5、若采用 Nginx 反向代理,不要使用 ACME 客户端在采用本示例的服务器上以 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书,因 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书需监听 80 或 443 端口,从而与当前应用端口冲突。 + +6、Caddy 版本不小于 v2.6.0 才支持 gRPC proxy 的 UDS 转发。 + +7、若采用 Caddy 反向代理,本示例 Caddy 支持自动 HTTPS,即自动申请与更新 TLS 证书,自动 HTTP 重定向到 HTTPS。 + +8、配置1:使用 Local Loopback 连接。配置2:使用 UDS 连接。 diff --git "a/V2Ray(VMess+gRPC)+Caddy\\Nginx/nginx_real.conf" "b/V2Ray(VMess+gRPC)+Caddy\\Nginx/nginx_real.conf" new file mode 100644 index 00000000000..6beaebf337b --- /dev/null +++ "b/V2Ray(VMess+gRPC)+Caddy\\Nginx/nginx_real.conf" @@ -0,0 +1,30 @@ +#ips-v4: +set_real_ip_from 103.21.244.0/22; +set_real_ip_from 103.22.200.0/22; +set_real_ip_from 103.31.4.0/22; +set_real_ip_from 104.16.0.0/13; +set_real_ip_from 104.24.0.0/14; +set_real_ip_from 108.162.192.0/18; +set_real_ip_from 131.0.72.0/22; +set_real_ip_from 141.101.64.0/18; +set_real_ip_from 162.158.0.0/15; +set_real_ip_from 172.64.0.0/13; +set_real_ip_from 173.245.48.0/20; +set_real_ip_from 188.114.96.0/20; +set_real_ip_from 190.93.240.0/20; +set_real_ip_from 197.234.240.0/22; +set_real_ip_from 198.41.128.0/17; +#ips-v6: +set_real_ip_from 2400:cb00::/32; +set_real_ip_from 2606:4700::/32; +set_real_ip_from 2803:f800::/32; +set_real_ip_from 2405:b500::/32; +set_real_ip_from 2405:8100::/32; +set_real_ip_from 2a06:98c0::/29; +set_real_ip_from 2c0f:f248::/32; +#real_ip_header CF-Connecting-IP; +real_ip_header X-Forwarded-For; +#ע +#1cloudflare ipsϢhttps://www.cloudflare.com/ipsʱ¡ +#2set_real_ip_fromӦIPΪֹãҪʵԶű㶨 +#3ʹCloudflare CDNԼset_real_ip_fromӦIP diff --git a/Xray(E+B+D+G+A)+Caddy(N)/1_caddy.json b/Xray(E+B+D+G+A)+Caddy(N)/1_caddy.json new file mode 100644 index 00000000000..605e31b3c13 --- /dev/null +++ b/Xray(E+B+D+G+A)+Caddy(N)/1_caddy.json @@ -0,0 +1,130 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "storage": { + "module": "file_system", + "root": "/home/tls" //存放TLS证书的基本路径 + }, + "apps": { + "http": { + "servers": { + "h1": { + "listen": [":80"], + "routes": [{ + "handle": [{ + "handler": "static_response", + "headers": { + "Location": ["https://{http.request.host}{http.request.uri}"] //HTTP自动跳转HTTPS,让网站看起来更真实。 + }, + "status_code": 301 + }] + }] + }, + "h1h2c": { + "listen": ["127.0.0.1:88"], //HTTP/1.1 server及H2C server本地监听端口 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }], + "routes": [{ + "match": [{ + "path": ["/SeuW56Es"] //与VLESS+H2C应用中path对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2005" //转发给本机VLESS+H2C监听端口 + }] + }] + }, + { + "match": [{ + "protocol": "grpc", + "path": ["/SALdGZ9k/*"] //与Shadowsocks+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2011" //转发给本机Shadowsocks+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "forward_proxy", + "auth_user_deprecated": "user", //NaiveProxy用户,修改为自己的。 + "auth_pass_deprecated": "pass", //NaiveProxy密码,修改为自己的。 + "hide_ip": true, + "hide_via": true, + "probe_resistance": {} + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2c"] //开启HTTP/1.1 server与H2C server支持 + } + } + }, + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、从Let's Encrypt申请的普通TLS证书在‘/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/z1.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,z1.xx.yy为域名,目录根据域名变化。 +//3、从ZeroSSL申请的普通TLS证书在‘/home/tls/certificates/acme.zerossl.com-v2-dv90/z1.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,z1.xx.yy为域名,目录根据域名变化。 +//4、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 diff --git a/Xray(E+B+D+G+A)+Caddy(N)/1_xray_config.json b/Xray(E+B+D+G+A)+Caddy(N)/1_xray_config.json new file mode 100644 index 00000000000..19f84ca43a9 --- /dev/null +++ b/Xray(E+B+D+G+A)+Caddy(N)/1_xray_config.json @@ -0,0 +1,202 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "path": "/HALdGZ9k", //通过路径分流 + "dest": 2001, //分流后转给VMess+WebSocket监听端口 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给如下VMess+WebSocket应用。1或2表示PROXY protocol版本。 + }, + { + "dest": 88, //h2与http/1.1回落端口(共用端口) + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/z1.xx.yy/z1.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/z1.xx.yy/z1.xx.yy.key" //换成自己的密钥,绝对路径。 + }, + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/z2.xx.yy/z2.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/z2.xx.yy/z2.xx.yy.key" //换成自己的密钥,绝对路径。 + } //若使用通配符证书,合并一组即可。 + ], + "rejectUnknownSni": true, //若接收到的SNI与证书域名不匹配就拒绝TLS握手(禁止以IP方式访问网站) + "minVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2001, //VMess+WebSocket监听端口 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "acceptProxyProtocol": true, //开启PROXY protocol接收,接收VLESS+Vision+TLS分流前真实来源IP和端口。 + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2005, //VLESS+H2C监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "httpSettings": { + "path": "/SeuW56Es" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} +//备注: +//1、本示例使用XTLS Vision配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 +//2、本示例使用不同域名来实现介绍中各应用,其办法如下: +//1)、VLESS+Vision+TLS仅使用z1.xx.yy域名。 +//2)、VMess+WebSocket+TLS仅使用z2.xx.yy域名。 +//3)、VLESS+H2C+TLS仅使用z1.xx.yy域名。 +//4)、Shadowsocks+gRPC+TLS仅使用z2.xx.yy域名。 +//5)、NaiveProxy仅使用z1.xx.yy域名(使用HTTPS协议)。 diff --git a/Xray(E+B+D+G+A)+Caddy(N)/2_caddy.json b/Xray(E+B+D+G+A)+Caddy(N)/2_caddy.json new file mode 100644 index 00000000000..93a03415f71 --- /dev/null +++ b/Xray(E+B+D+G+A)+Caddy(N)/2_caddy.json @@ -0,0 +1,130 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "storage": { + "module": "file_system", + "root": "/home/tls" //存放TLS证书的基本路径 + }, + "apps": { + "http": { + "servers": { + "h1": { + "listen": [":80"], + "routes": [{ + "handle": [{ + "handler": "static_response", + "headers": { + "Location": ["https://{http.request.host}{http.request.uri}"] //HTTP自动跳转HTTPS,让网站看起来更真实。 + }, + "status_code": 301 + }] + }] + }, + "h1h2c": { + "listen": ["unix/@h1h2c"], //HTTP/1.1 server及H2C server监听进程 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }], + "routes": [{ + "match": [{ + "path": ["/SeuW56Es"] //与VLESS+H2C应用中path对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "unix/@vlessh2c" //转发给本机VLESS+H2C监听进程 + }] + }] + }, + { + "match": [{ + "protocol": "grpc", + "path": ["/SALdGZ9k/*"] //与Shadowsocks+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2011" //转发给本机Shadowsocks+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "forward_proxy", + "auth_user_deprecated": "user", //NaiveProxy用户,修改为自己的。 + "auth_pass_deprecated": "pass", //NaiveProxy密码,修改为自己的。 + "hide_ip": true, + "hide_via": true, + "probe_resistance": {} + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2c"] //开启HTTP/1.1 server与H2C server支持 + } + } + }, + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、从Let's Encrypt申请的普通TLS证书在‘/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/z1.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,z1.xx.yy为域名,目录根据域名变化。 +//3、从ZeroSSL申请的普通TLS证书在‘/home/tls/certificates/acme.zerossl.com-v2-dv90/z1.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,z1.xx.yy为域名,目录根据域名变化。 +//4、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 diff --git a/Xray(E+B+D+G+A)+Caddy(N)/2_xray_config.json b/Xray(E+B+D+G+A)+Caddy(N)/2_xray_config.json new file mode 100644 index 00000000000..13de3cb4834 --- /dev/null +++ b/Xray(E+B+D+G+A)+Caddy(N)/2_xray_config.json @@ -0,0 +1,200 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "path": "/HALdGZ9k", //通过路径分流 + "dest": "@vmessws", //分流后转给VMess+WebSocket监听进程 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给如下VMess+WebSocket应用。1或2表示PROXY protocol版本。 + }, + { + "dest": "@h1h2c", //h2与http/1.1回落进程(共用进程) + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/z1.xx.yy/z1.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/z1.xx.yy/z1.xx.yy.key" //换成自己的密钥,绝对路径。 + }, + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/z2.xx.yy/z2.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/z2.xx.yy/z2.xx.yy.key" //换成自己的密钥,绝对路径。 + } //若使用通配符证书,合并一组即可。 + ], + "rejectUnknownSni": true, //若接收到的SNI与证书域名不匹配就拒绝TLS握手(禁止以IP方式访问网站) + "minVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256" + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@vmessws", //VMess+WebSocket监听进程 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "acceptProxyProtocol": true, //开启PROXY protocol接收,接收VLESS+Vision+TLS分流前真实来源IP和端口。 + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@vlessh2c", //VLESS+H2C监听进程 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "httpSettings": { + "path": "/SeuW56Es" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} +//备注: +//1、本示例使用XTLS Vision配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 +//2、本示例使用不同域名来实现介绍中各应用,其办法如下: +//1)、VLESS+Vision+TLS仅使用z1.xx.yy域名。 +//2)、VMess+WebSocket+TLS仅使用z2.xx.yy域名。 +//3)、VLESS+H2C+TLS仅使用z1.xx.yy域名。 +//4)、Shadowsocks+gRPC+TLS仅使用z2.xx.yy域名。 +//5)、NaiveProxy仅使用z1.xx.yy域名(使用HTTPS协议)。 diff --git a/Xray(E+B+D+G+A)+Caddy(N)/README.md b/Xray(E+B+D+G+A)+Caddy(N)/README.md new file mode 100644 index 00000000000..89c66ca2012 --- /dev/null +++ b/Xray(E+B+D+G+A)+Caddy(N)/README.md @@ -0,0 +1,33 @@ +介绍: + +Xray 前置(监听 443 端口),利用 VLESS+Vision+TLS 回落及分流 WebSocket 特性与 Caddy 为 H2C 与 gRPC 提供反向代理、为 forwardproxy 插件提供正向代理,实现除 Xray 的 mKCP 应用外共用 443 端口,其应用如下: + +1、E=VLESS+Vision+TLS(回落/分流配置,TLS 由自己启用及处理。) + +2、B=VMess+WebSocket+TLS(TLS 由 VLESS+Vision+TLS 启用及处理,不需配置。) + +3、D=VLESS+H2C+TLS(TLS 由 VLESS+Vision+TLS 启用及处理,不需配置。) + +4、G=Shadowsocks+gRPC+TLS(TLS 由 VLESS+Vision+TLS 启用及处理,不需配置。) + +5、A=VLESS+mKCP+seed + +6、N=NaiveProxy(基于 Caddy 的改进版 forwardproxy 插件实现,TLS 由 VLESS+Vision+TLS 启用及处理,不需配置。) + +注意: + +1、Xray 的监听地址不支持 Shadowsocks 协议使用 UDS 监听。 + +2、Xray 版本不小于 v1.7.2 才完美支持 VLESS 协议的 XTLS Vision 应用。 + +3、Caddy 版本不小于 v2.6.0 才支持 H2C/gRPC proxy 的 UDS 转发。 + +4、Caddy 支持 HTTP/1.1 server 与 H2C server 共用一个端口或一个进程。 + +5、使用本人 Releases 中编译好的 Caddy 文件,可同时支持 H2C server、H2C/gRPC proxy、NaiveProxy、Trojan-Go 等应用。 + +6、本示例 NaiveProxy 仅支持 HTTP/2 代理应用,即 HTTPS 协议传输。 + +7、本示例所需 TLS 证书由 Caddy(内置 ACME 客户端) 提供,实现 TLS 证书自动申请及更新。 + +8、配置1:使用 Local Loopback 连接,且启用了 PROXY protocol。配置2:使用 UDS 连接(对应 Shadowsocks+gRPC+TLS 除外),且启用了 PROXY protocol。 diff --git a/Xray(E+B+D+G+A)+Caddy(N)/xray_SS-2022_config.json b/Xray(E+B+D+G+A)+Caddy(N)/xray_SS-2022_config.json new file mode 100644 index 00000000000..87803a31d96 --- /dev/null +++ b/Xray(E+B+D+G+A)+Caddy(N)/xray_SS-2022_config.json @@ -0,0 +1,46 @@ +//Shadowsocks-2022配置 +//原配置: +//........<省略>........ + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//以上配置修改为如下: +//单用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-chacha20-poly1305", //Shadowsocks-2022加密方法之一 + "password": "81qjRtwJZWx2gBphrLk18WZQ06B3Y2Vxlnqe903xXqU=", //修改为自己的密钥 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//多用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-aes-128-gcm", //Shadowsocks-2022加密方法之一 + "password": "rvQ6fK6Y4ckgFVslZlZUgQ==", //修改为自己的主项密钥 + "clients": [ + { + "password": "FPTg9fyNve167Fg8oPkFlQ==", //修改为自己的分项密钥 + "email": "2011@gmail.com" + }, + { + "password": "dkv04xu1f+UeM3mXpNJgVA==", //修改为自己的分项密钥 + "email": "2021@gmail.com" + } + ] + }, +//........<省略>........ +//备注: +//1、Xray从v1.5.9版开始支持Shadowsocks-2022。 +//2、密钥生成及长度 +//在服务器上直接使用‘openssl rand -base64 <长度> ’命令生成符合如下加密方法的对应密钥。 +// 加密方法 密钥长度 +//2022-blake3-aes-128-gcm 16 +//2022-blake3-aes-256-gcm 32 +//2022-blake3-chacha20-poly1305 32 +//3、多用户的客户端的密钥为主项密钥:分项密钥的组合,如rvQ6fK6Y4ckgFVslZlZUgQ==:FPTg9fyNve167Fg8oPkFlQ==。 diff --git a/Xray(E+B+G+A)+Nginx/1_nginx.conf b/Xray(E+B+G+A)+Nginx/1_nginx.conf new file mode 100644 index 00000000000..aa2ff3f7863 --- /dev/null +++ b/Xray(E+B+G+A)+Nginx/1_nginx.conf @@ -0,0 +1,70 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 127.0.0.1:81 proxy_protocol; #HTTP/1.1 server本地监听端口与开启PROXY protocol接收 + set_real_ip_from 127.0.0.1; + real_ip_header proxy_protocol; + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen 127.0.0.1:82 http2 proxy_protocol; #H2C server本地监听端口与开启PROXY protocol接收 + set_real_ip_from 127.0.0.1; + real_ip_header X-Forwarded-For; + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} diff --git a/Xray(E+B+G+A)+Nginx/1_xray_config.json b/Xray(E+B+G+A)+Nginx/1_xray_config.json new file mode 100644 index 00000000000..b12bf921fa4 --- /dev/null +++ b/Xray(E+B+G+A)+Nginx/1_xray_config.json @@ -0,0 +1,177 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "path": "/HALdGZ9k", //通过路径分流 + "dest": 2001, //分流后转给VMess+WebSocket监听端口 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给如下VMess+WebSocket应用。1或2表示PROXY protocol版本。 + }, + { + "alpn": "h2", //h2回落匹配 + "dest": 82, //h2回落端口 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + }, + { + "dest": 81, //http/1.1回落端口 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/z1.xx.yy/z1.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/z1.xx.yy/z1.xx.yy.key" //换成自己的密钥,绝对路径。 + }, + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/z2.xx.yy/z2.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/z2.xx.yy/z2.xx.yy.key" //换成自己的密钥,绝对路径。 + } //若使用通配符证书或SAN证书,合并一组即可。 + ], + "rejectUnknownSni": true, //若接收到的SNI与证书域名不匹配就拒绝TLS握手(禁止以IP方式访问网站) + "minVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" //若无RSA证书,可删除所有RSA算法的密码套件;无ECC证书,可删除所有ECDSA算法的密码套件。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2001, //VMess+WebSocket监听端口 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "acceptProxyProtocol": true, //开启PROXY protocol接收,接收VLESS+Vision+TLS分流前真实来源IP和端口。 + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} +//备注: +//1、本示例使用XTLS Vision配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 +//2、本示例使用不同域名来实现介绍中各应用,其办法如下: +//1)、VLESS+Vision+TLS仅使用z1.xx.yy域名。 +//2)、VMess+WebSocket+TLS仅使用z2.xx.yy域名。 +//3)、Shadowsocks+gRPC+TLS仅使用z2.xx.yy域名。 diff --git a/Xray(E+B+G+A)+Nginx/2_nginx.conf b/Xray(E+B+G+A)+Nginx/2_nginx.conf new file mode 100644 index 00000000000..947cc641cff --- /dev/null +++ b/Xray(E+B+G+A)+Nginx/2_nginx.conf @@ -0,0 +1,70 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen unix:/dev/shm/h1.sock proxy_protocol; #HTTP/1.1 server监听进程与开启PROXY protocol接收 + set_real_ip_from unix:; + real_ip_header proxy_protocol; + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen unix:/dev/shm/h2c.sock http2 proxy_protocol; #H2C server监听进程与开启PROXY protocol接收 + set_real_ip_from unix:; + real_ip_header X-Forwarded-For; + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} diff --git a/Xray(E+B+G+A)+Nginx/2_xray_config.json b/Xray(E+B+G+A)+Nginx/2_xray_config.json new file mode 100644 index 00000000000..c0955d26126 --- /dev/null +++ b/Xray(E+B+G+A)+Nginx/2_xray_config.json @@ -0,0 +1,176 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "path": "/HALdGZ9k", //通过路径分流 + "dest": "@vmessws", //分流后转给VMess+WebSocket监听进程 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给如下VMess+WebSocket应用。1或2表示PROXY protocol版本。 + }, + { + "alpn": "h2", //h2回落匹配 + "dest": "/dev/shm/h2c.sock", //h2回落进程 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + }, + { + "dest": "/dev/shm/h1.sock", //http/1.1回落进程 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/z1.xx.yy/z1.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/z1.xx.yy/z1.xx.yy.key" //换成自己的密钥,绝对路径。 + }, + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/z2.xx.yy/z2.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/z2.xx.yy/z2.xx.yy.key" //换成自己的密钥,绝对路径。 + } //若使用通配符证书或SAN证书,合并一组即可。 + ], + "rejectUnknownSni": true, //若接收到的SNI与证书域名不匹配就拒绝TLS握手(禁止以IP方式访问网站) + "minVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384:TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256:TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256" //若无RSA证书,可删除所有RSA算法的密码套件;无ECC证书,可删除所有ECDSA算法的密码套件。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@vmessws", //VMess+WebSocket监听进程 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "acceptProxyProtocol": true, //开启PROXY protocol接收,接收VLESS+Vision+TLS分流前真实来源IP和端口。 + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} +//备注: +//1、本示例使用XTLS Vision配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 +//2、本示例使用不同域名来实现介绍中各应用,其办法如下: +//1)、VLESS+Vision+TLS仅使用z1.xx.yy域名。 +//2)、VMess+WebSocket+TLS仅使用z2.xx.yy域名。 +//3)、Shadowsocks+gRPC+TLS仅使用z2.xx.yy域名。 diff --git a/Xray(E+B+G+A)+Nginx/README.md b/Xray(E+B+G+A)+Nginx/README.md new file mode 100644 index 00000000000..ca286b09a85 --- /dev/null +++ b/Xray(E+B+G+A)+Nginx/README.md @@ -0,0 +1,27 @@ +介绍: + +Xray 前置(监听 443 端口),利用 VLESS+Vision+TLS 回落及分流 WebSocket 特性与 Nginx 为 gRPC 提供反向代理,实现除 Xray 的 mKCP 应用外共用 443 端口,其应用如下: + +1、E=VLESS+Vision+TLS(回落/分流配置,TLS 由自己启用及处理。) + +2、B=VMess+WebSocket+TLS(TLS 由 VLESS+Vision+TLS 启用及处理,不需配置。) + +3、G=Shadowsocks+gRPC+TLS(TLS 由 VLESS+Vision+TLS 启用及处理,不需配置。) + +4、A=VLESS+mKCP+seed + +注意: + +1、Xray 的监听地址不支持 Shadowsocks 协议使用 UDS 监听。 + +2、Xray 版本不小于 v1.7.2 才完美支持 VLESS 协议的 XTLS Vision 应用。 + +3、Nginx 支持 H2C server 及 gRPC proxy 需要 Nginx 包含 http_v2_module 模块。 + +4、Nginx 支持 H2C server,但不支持 HTTP/1.1 server 与 H2C server 共用一个端口或一个进程;故回落分成 http/1.1 回落与 h2 回落分别对应 Nginx 的 HTTP/1.1 server 与 H2C server。 + +5、Nginx 支持请求标头还原为真实客户端地址需要 Nginx 包含 http_realip_module 模块。 + +6、不要使用 ACME 客户端在采用本示例的服务器上以 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书,因 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书需监听 80 或 443 端口,从而与当前应用端口冲突。 + +7、配置1:使用 Local Loopback 连接,且启用了 PROXY protocol。配置2:使用 UDS 连接(对应 Shadowsocks+gRPC+TLS 除外),且启用了 PROXY protocol。 diff --git a/Xray(E+B+G+A)+Nginx/xray_SS-2022_config.json b/Xray(E+B+G+A)+Nginx/xray_SS-2022_config.json new file mode 100644 index 00000000000..87803a31d96 --- /dev/null +++ b/Xray(E+B+G+A)+Nginx/xray_SS-2022_config.json @@ -0,0 +1,46 @@ +//Shadowsocks-2022配置 +//原配置: +//........<省略>........ + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//以上配置修改为如下: +//单用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-chacha20-poly1305", //Shadowsocks-2022加密方法之一 + "password": "81qjRtwJZWx2gBphrLk18WZQ06B3Y2Vxlnqe903xXqU=", //修改为自己的密钥 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//多用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-aes-128-gcm", //Shadowsocks-2022加密方法之一 + "password": "rvQ6fK6Y4ckgFVslZlZUgQ==", //修改为自己的主项密钥 + "clients": [ + { + "password": "FPTg9fyNve167Fg8oPkFlQ==", //修改为自己的分项密钥 + "email": "2011@gmail.com" + }, + { + "password": "dkv04xu1f+UeM3mXpNJgVA==", //修改为自己的分项密钥 + "email": "2021@gmail.com" + } + ] + }, +//........<省略>........ +//备注: +//1、Xray从v1.5.9版开始支持Shadowsocks-2022。 +//2、密钥生成及长度 +//在服务器上直接使用‘openssl rand -base64 <长度> ’命令生成符合如下加密方法的对应密钥。 +// 加密方法 密钥长度 +//2022-blake3-aes-128-gcm 16 +//2022-blake3-aes-256-gcm 32 +//2022-blake3-chacha20-poly1305 32 +//3、多用户的客户端的密钥为主项密钥:分项密钥的组合,如rvQ6fK6Y4ckgFVslZlZUgQ==:FPTg9fyNve167Fg8oPkFlQ==。 diff --git a/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/1_caddy.json b/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/1_caddy.json new file mode 100644 index 00000000000..a816c5e6b1d --- /dev/null +++ b/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/1_caddy.json @@ -0,0 +1,186 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "storage": { + "module": "file_system", + "root": "/home/tls" //存放TLS证书的基本路径 + }, + "apps": { + "http": { + "servers": { + "h1": { + "listen": [":80"], + "routes": [{ + "handle": [{ + "handler": "static_response", + "headers": { + "Location": ["https://{http.request.host}{http.request.uri}"] //HTTP自动跳转HTTPS,让网站看起来更真实。 + }, + "status_code": 301 + }] + }] + }, + "h1h2c": { + "listen": ["127.0.0.1:88"], //HTTP/1.1 server及H2C server本地监听端口 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }], + "routes": [{ + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "protocols": ["h1","h2c"] //开启HTTP/1.1 server与H2C server支持 + }, + "https": { + "listen": ["127.0.0.1:7443"], //HTTPS server本地监听端口 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }, + { + "wrapper": "tls" //HTTPS server开启PROXY protocol接收必须配置 + }], + "routes": [{ + "match": [{ + "path": ["/HALdGZ9k"], //与VMess+WebSocket应用中path对应 + "header": { + "Connection": ["*Upgrade*"], + "Upgrade": ["websocket"] + } + }], + "handle": [{ + "handler": "reverse_proxy", + "upstreams": [{ + "dial": "127.0.0.1:2001" //转发给本机VMess+WebSocket监听端口 + }] + }] + }, + { + "match": [{ + "path": ["/SeuW56Es"] //与VLESS+H2C应用中path对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2005" //转发给本机VLESS+H2C监听端口 + }] + }] + }, + { + "match": [{ + "protocol": "grpc", + "path": ["/SALdGZ9k/*"] //与Shadowsocks+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2011" //转发给本机Shadowsocks+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "forward_proxy", + "auth_user_deprecated": "user", //NaiveProxy用户,修改为自己的。 + "auth_pass_deprecated": "pass", //NaiveProxy密码,修改为自己的。 + "hide_ip": true, + "hide_via": true, + "probe_resistance": {} + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接,修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["zh.xx.yy","h3.xx.yy"] //限定域名连接,修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2","h3"] //默认配置 + } + } + }, + "tls": { + "certificates": { + "automate": ["zv.xx.yy","zt.xx.yy","zh.xx.yy","z1.xx.yy","h3.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、从Let's Encrypt申请的普通TLS证书在‘/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zv.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,zv.xx.yy为域名,目录根据域名变化。 +//3、从ZeroSSL申请的普通TLS证书在‘/home/tls/certificates/acme.zerossl.com-v2-dv90/zv.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,zv.xx.yy为域名,目录根据域名变化。 +//4、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//5、本配置支持套CDN(zh.xx.yy)、非AES算法的密码套件配置(z1.xx.yy)及HTTP/3代理(h3.xx.yy)。 diff --git a/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/1_nginx.conf b/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/1_nginx.conf new file mode 100644 index 00000000000..8dbf05c08f7 --- /dev/null +++ b/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/1_nginx.conf @@ -0,0 +1,53 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +stream { + map $ssl_preread_server_name $backend_name { + zv.xx.yy vless; #zv.xx.yy为对应VLESS+Vision+TLS的域名,修改为自己的。 + zt.xx.yy trojan; #zt.xx.yy为对应Trojan+TCP+TLS的域名,修改为自己的。 + zh.xx.yy https; #zh.xx.yy为对应HTTPS server的域名,修改为自己的。 + z1.xx.yy https; #z1.xx.yy为对应HTTPS server的域名,修改为自己的。 + h3.xx.yy https; #h3.xx.yy为对应HTTPS server的域名,修改为自己的。 + } #禁止以IP方式访问网站 + upstream vless { + server 127.0.0.1:5443; #转给VLESS+TCP+TLS本地监听端口 + } + upstream trojan { + server 127.0.0.1:6443; #转给Trojan+TCP+TLS本地监听端口 + } + upstream https { + server 127.0.0.1:7443; #转给HTTPS server本地监听端口 + } + server { + listen 443; + listen [::]:443; #无IPv6,此项可以删除。 + ssl_preread on; + proxy_pass $backend_name; + proxy_protocol on; #启用PROXY protocol发送(全局模式) + } + + server { + listen 443 udp; + listen [::]:443 udp; #无IPv6,此项可以删除。 + proxy_pass 127.0.0.1:7443; #转给HTTPS server本地监听端口 + } #定向UDP转发配置 +} +#备注: +#1、本示例使用XTLS Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)、套CDN(zh.xx.yy)、非AES算法的密码套件配置(z1.xx.yy)来避免被封。 +#2、本示例使用不同域名来实现介绍中各应用,其办法如下: +#1)、VLESS+Vision+TLS仅使用zv.xx.yy域名。 +#2)、Trojan+TCP+TLS仅使用zt.xx.yy域名。 +#3)、VMess+WebSocket+TLS仅使用zh.xx.yy域名。 +#4)、VLESS+H2C+TLS仅使用z1.xx.yy域名。 +#5)、Shadowsocks+gRPC+TLS可使用zh.xx.yy域名或z1.xx.yy域名,推荐使用z1.xx.yy域名。 +#6)、NaiveProxy使用HTTPS协议时用z1.xx.yy域名,使用QUIC协议时用h3.xx.yy域名。 +#3、本示例无Nginx在用网站应用,如需要请自行增加。调整请参考Xray(E+F+B+G+A)+Nginx示例中Nginx配置。 diff --git a/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/1_xray_config.json b/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/1_xray_config.json new file mode 100644 index 00000000000..c5b8006a354 --- /dev/null +++ b/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/1_xray_config.json @@ -0,0 +1,232 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 5443, //VLESS+Vision+TLS监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "5443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": 88, //h2与http/1.1回落端口(共用端口) + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。多级传递,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zv.xx.yy/zv.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zv.xx.yy/zv.xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "minVersion": "1.2" + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Caddy SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 6443, //Trojan+TCP+TLS监听端口 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy6443", //修改为自己密码 + "email": "6443@gmail.com" + } + ], + "fallbacks": [ + { + "dest": 88, //h2与http/1.1回落端口(共用端口) + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。与上一致,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zt.xx.yy/zt.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zt.xx.yy/zt.xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "minVersion": "1.2", + "maxVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" //非AES算法的密码套件 + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Caddy SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2001, //VMess+WebSocket监听端口 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2005, //VLESS+H2C监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "httpSettings": { + "path": "/SeuW56Es" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} +//备注: +//1、本配置支持XTLS Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)。 diff --git a/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/2_caddy.json b/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/2_caddy.json new file mode 100644 index 00000000000..8eb96a9b687 --- /dev/null +++ b/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/2_caddy.json @@ -0,0 +1,186 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "storage": { + "module": "file_system", + "root": "/home/tls" //存放TLS证书的基本路径 + }, + "apps": { + "http": { + "servers": { + "h1": { + "listen": [":80"], + "routes": [{ + "handle": [{ + "handler": "static_response", + "headers": { + "Location": ["https://{http.request.host}{http.request.uri}"] //HTTP自动跳转HTTPS,让网站看起来更真实。 + }, + "status_code": 301 + }] + }] + }, + "h1h2c": { + "listen": ["unix/@h1h2c"], //HTTP/1.1 server及H2C server监听进程 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }], + "routes": [{ + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "protocols": ["h1","h2c"] //开启HTTP/1.1 server与H2C server支持 + }, + "https": { + "listen": ["127.0.0.1:7443"], //HTTPS server本地监听端口 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }, + { + "wrapper": "tls" //HTTPS server开启PROXY protocol接收必须配置 + }], + "routes": [{ + "match": [{ + "path": ["/HALdGZ9k"], //与VMess+WebSocket应用中path对应 + "header": { + "Connection": ["*Upgrade*"], + "Upgrade": ["websocket"] + } + }], + "handle": [{ + "handler": "reverse_proxy", + "upstreams": [{ + "dial": "unix/@vmessws" //转发给本机VMess+WebSocket监听进程 + }] + }] + }, + { + "match": [{ + "path": ["/SeuW56Es"] //与VLESS+H2C应用中path对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "unix/@vlessh2c" //转发给本机VLESS+H2C监听进程 + }] + }] + }, + { + "match": [{ + "protocol": "grpc", + "path": ["/SALdGZ9k/*"] //与Shadowsocks+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2011" //转发给本机Shadowsocks+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "forward_proxy", + "auth_user_deprecated": "user", //NaiveProxy用户,修改为自己的。 + "auth_pass_deprecated": "pass", //NaiveProxy密码,修改为自己的。 + "hide_ip": true, + "hide_via": true, + "probe_resistance": {} + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接,修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["zh.xx.yy","h3.xx.yy"] //限定域名连接,修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2","h3"] //默认配置 + } + } + }, + "tls": { + "certificates": { + "automate": ["zv.xx.yy","zt.xx.yy","zh.xx.yy","z1.xx.yy","h3.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、从Let's Encrypt申请的普通TLS证书在‘/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zv.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,zv.xx.yy为域名,目录根据域名变化。 +//3、从ZeroSSL申请的普通TLS证书在‘/home/tls/certificates/acme.zerossl.com-v2-dv90/zv.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,zv.xx.yy为域名,目录根据域名变化。 +//4、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//5、本配置支持套CDN(zh.xx.yy)、非AES算法的密码套件配置(z1.xx.yy)及HTTP/3代理(h3.xx.yy)。 diff --git a/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/2_nginx.conf b/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/2_nginx.conf new file mode 100644 index 00000000000..16506609d93 --- /dev/null +++ b/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/2_nginx.conf @@ -0,0 +1,53 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +stream { + map $ssl_preread_server_name $backend_name { + zv.xx.yy vless; #zv.xx.yy为对应VLESS+Vision+TLS的域名,修改为自己的。 + zt.xx.yy trojan; #zt.xx.yy为对应Trojan+TCP+TLS的域名,修改为自己的。 + zh.xx.yy https; #zh.xx.yy为对应HTTPS server的域名,修改为自己的。 + z1.xx.yy https; #z1.xx.yy为对应HTTPS server的域名,修改为自己的。 + h3.xx.yy https; #h3.xx.yy为对应HTTPS server的域名,修改为自己的。 + } #禁止以IP方式访问网站 + upstream vless { + server unix:/dev/shm/vless.sock; #转给VLESS+TCP+TLS监听进程 + } + upstream trojan { + server unix:/dev/shm/trojan.sock; #转给Trojan+TCP+TLS监听进程 + } + upstream https { + server 127.0.0.1:7443; #转给HTTPS server本地监听端口 + } + server { + listen 443; + listen [::]:443; #无IPv6,此项可以删除。 + ssl_preread on; + proxy_pass $backend_name; + proxy_protocol on; #启用PROXY protocol发送(全局模式) + } + + server { + listen 443 udp; + listen [::]:443 udp; #无IPv6,此项可以删除。 + proxy_pass 127.0.0.1:7443; #转给HTTPS server本地监听端口 + } #定向UDP转发配置 +} +#备注: +#1、本示例使用XTLS Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)、套CDN(zh.xx.yy)、非AES算法的密码套件配置(z1.xx.yy)来避免被封。 +#2、本示例使用不同域名来实现介绍中各应用,其办法如下: +#1)、VLESS+Vision+TLS仅使用zv.xx.yy域名。 +#2)、Trojan+TCP+TLS仅使用zt.xx.yy域名。 +#3)、VMess+WebSocket+TLS仅使用zh.xx.yy域名。 +#4)、VLESS+H2C+TLS仅使用z1.xx.yy域名。 +#5)、Shadowsocks+gRPC+TLS可使用zh.xx.yy域名或z1.xx.yy域名,推荐使用z1.xx.yy域名。 +#6)、NaiveProxy使用HTTPS协议时用z1.xx.yy域名,使用QUIC协议时用h3.xx.yy域名。 +#3、本示例无Nginx在用网站应用,如需要请自行增加。调整请参考Xray(E+F+B+G+A)+Nginx示例中Nginx配置。 diff --git a/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/2_xray_config.json b/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/2_xray_config.json new file mode 100644 index 00000000000..35f41653764 --- /dev/null +++ b/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/2_xray_config.json @@ -0,0 +1,228 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "listen": "/dev/shm/vless.sock", /VLESS+Vision+TLS监听进程 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "5443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": "@h1h2c", //h2与http/1.1回落进程(共用进程) + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。多级传递,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zv.xx.yy/zv.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zv.xx.yy/zv.xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "minVersion": "1.2" + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Caddy SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "/dev/shm/trojan.sock", //Trojan+TCP+TLS监听进程 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy6443", //修改为自己密码 + "email": "6443@gmail.com" + } + ], + "fallbacks": [ + { + "dest": "@h1h2c", //h2与http/1.1回落进程(共用进程) + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。与上一致,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zt.xx.yy/zt.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zt.xx.yy/zt.xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "minVersion": "1.2", + "maxVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" //非AES算法的密码套件 + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Caddy SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@vmessws", //VMess+WebSocket监听进程 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@vlessh2c", //VLESS+H2C监听进程 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "httpSettings": { + "path": "/SeuW56Es" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} +//备注: +//1、本配置支持XTLS Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)。 diff --git a/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/README.md b/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/README.md new file mode 100644 index 00000000000..8d59935e11f --- /dev/null +++ b/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/README.md @@ -0,0 +1,41 @@ +介绍: + +利用 Nginx 支持 SNI 分流特性,对 VLESS+Vision+TLS、Trojan+TCP+TLS、HTTPS server 进行 SNI 分流(四层转发),实现除 Xray 的 mKCP 应用外共用 443 端口。其中 Caddy 为 VLESS+Vision+TLS 与 Trojan+TCP+TLS 提供回落服务(WEB 服务),为 Xray 的 WebSocket、H2C、gRPC 提供反向代理,为 forwardproxy 插件提供正向代理,其应用如下: + +1、E=VLESS+Vision+TLS(回落/分流配置,TLS 由自己启用及处理。) + +2、F=Trojan+TCP+TLS(回落/分流配置,TLS 由自己启用及处理。) + +3、B=VMess+WebSocket+TLS(TLS 由 Caddy 提供及处理,不需配置。) + +4、D=VLESS+H2C+TLS(TLS 由 Caddy 提供及处理,不需配置。) + +5、G=Shadowsocks+gRPC+TLS(TLS 由 Caddy 提供及处理,不需配置。) + +6、A=VLESS+mKCP+seed + +7、N=NaiveProxy(基于 Caddy 的改进版 forwardproxy 插件实现,TLS 由 Caddy 提供及处理。) + +注意: + +1、Nginx 支持 SNI 分流需要 Nginx 包含 stream_core_module 和 stream_ssl_preread_module 模块。 + +2、Xray 版本不小于 v1.7.2 才完美支持 VLESS 协议的 XTLS Vision 应用。 + +3、Xray 的监听地址不支持 Shadowsocks 协议使用 UDS 监听。 + +4、Caddy 版本不小于 v2.6.0 才支持 H2C/gRPC proxy 的 UDS 转发。 + +5、Caddy 支持 HTTP/1.1 server 与 H2C server 共用一个端口或一个进程。 + +6、使用本人 Releases 中编译好的 Caddy 文件,可同时支持 H2C server、H2C/gRPC proxy、NaiveProxy 等应用。 + +7、本示例 NaiveProxy 除了支持 HTTP/2 代理应用,还同时支持 HTTP/3 代理应用,即 QUIC 协议传输。若 NaiveProxy 使用 HTTP/3 代理应用,建议增加 [UDP 接收缓冲区大小](https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size)。 + +8、本示例所需 TLS 证书由 Caddy(内置 ACME 客户端) 提供,实现 TLS 证书自动申请及更新。 + +9、配置1:使用 Local Loopback 连接,且启用了 PROXY protocol。配置2:使用 UDS 连接(对应 HTTPS server、Shadowsocks+gRPC+TLS 除外),且启用了 PROXY protocol。 + +10、本示例 F 兼容原版 Trojan 的服务端应用,即可使用 Trojan 或 Trojan-Go 客户端连接。 + +11、若仅实现科学上网、且不需要 NaiveProxy 支持 HTTP/3 代理应用,推荐采用 [Xray(E+F+B+D+G+A)+Caddy(N)](https://github.com/lxhao61/integrated-examples/tree/main/Xray(E%2BF%2BB%2BD%2BG%2BA)%2BCaddy(N)) 示例。 diff --git a/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/xray_SS-2022_config.json b/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/xray_SS-2022_config.json new file mode 100644 index 00000000000..87803a31d96 --- /dev/null +++ b/Xray(E+F+B+D+G+A)+Caddy(N)+Nginx/xray_SS-2022_config.json @@ -0,0 +1,46 @@ +//Shadowsocks-2022配置 +//原配置: +//........<省略>........ + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//以上配置修改为如下: +//单用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-chacha20-poly1305", //Shadowsocks-2022加密方法之一 + "password": "81qjRtwJZWx2gBphrLk18WZQ06B3Y2Vxlnqe903xXqU=", //修改为自己的密钥 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//多用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-aes-128-gcm", //Shadowsocks-2022加密方法之一 + "password": "rvQ6fK6Y4ckgFVslZlZUgQ==", //修改为自己的主项密钥 + "clients": [ + { + "password": "FPTg9fyNve167Fg8oPkFlQ==", //修改为自己的分项密钥 + "email": "2011@gmail.com" + }, + { + "password": "dkv04xu1f+UeM3mXpNJgVA==", //修改为自己的分项密钥 + "email": "2021@gmail.com" + } + ] + }, +//........<省略>........ +//备注: +//1、Xray从v1.5.9版开始支持Shadowsocks-2022。 +//2、密钥生成及长度 +//在服务器上直接使用‘openssl rand -base64 <长度> ’命令生成符合如下加密方法的对应密钥。 +// 加密方法 密钥长度 +//2022-blake3-aes-128-gcm 16 +//2022-blake3-aes-256-gcm 32 +//2022-blake3-chacha20-poly1305 32 +//3、多用户的客户端的密钥为主项密钥:分项密钥的组合,如rvQ6fK6Y4ckgFVslZlZUgQ==:FPTg9fyNve167Fg8oPkFlQ==。 diff --git a/Xray(E+F+B+D+G+A)+Caddy(N)/1_caddy.json b/Xray(E+F+B+D+G+A)+Caddy(N)/1_caddy.json new file mode 100644 index 00000000000..23e6d5d83d8 --- /dev/null +++ b/Xray(E+F+B+D+G+A)+Caddy(N)/1_caddy.json @@ -0,0 +1,242 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "storage": { + "module": "file_system", + "root": "/home/tls" //存放TLS证书的基本路径 + }, + "apps": { + "layer4": { + "servers": { + "sni": { + "listen": [":443"], + "routes": [{ + "match": [{ + "tls": { + "sni": ["zv.xx.yy"] //对应VLESS+Vision+TLS的域名(禁止以IP方式访问网站),修改为自己的。 + } + }], + "handle": [{ + "handler": "proxy", + "upstreams": [{ + "dial": ["127.0.0.1:5443"] //转给VLESS+Vision+TLS本地监听端口 + }], + "proxy_protocol": "v2" //启用PROXY protocol发送。v1或v2表示PROXY protocol版本,建议采用v2版。 + }] + }, + { + "match": [{ + "tls": { + "sni": ["zt.xx.yy"] //对应Trojan+TCP+TLS的域名(禁止以IP方式访问网站),修改为自己的。 + } + }], + "handle": [{ + "handler": "proxy", + "upstreams": [{ + "dial": ["127.0.0.1:6443"] //转给Trojan+TCP+TLS本地监听端口 + }], + "proxy_protocol": "v2" //启用PROXY protocol发送。v1或v2表示PROXY protocol版本,建议采用v2版。 + }] + }, + { + "match": [{ + "tls": { + "sni": ["zh.xx.yy","z1.xx.yy"] //对应HTTPS server的域名(禁止以IP方式访问网站),修改为自己的。 + } + }], + "handle": [{ + "handler": "proxy", + "upstreams": [{ + "dial": ["127.0.0.1:7443"] //转给HTTPS server本地监听端口 + }], + "proxy_protocol": "v2" //启用PROXY protocol发送。v1或v2表示PROXY protocol版本,建议采用v2版。 + }] + }] + } + } + }, + "http": { + "servers": { + "h1": { + "listen": [":80"], + "routes": [{ + "handle": [{ + "handler": "static_response", + "headers": { + "Location": ["https://{http.request.host}{http.request.uri}"] //HTTP自动跳转HTTPS,让网站看起来更真实。 + }, + "status_code": 301 + }] + }] + }, + "h1h2c": { + "listen": ["127.0.0.1:88"], //HTTP/1.1 server及H2C server本地监听端口 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }], + "routes": [{ + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "protocols": ["h1","h2c"] //开启HTTP/1.1 server与H2C server支持 + }, + "https": { + "listen": ["127.0.0.1:7443"], //HTTPS server本地监听端口 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }, + { + "wrapper": "tls" //HTTPS server开启PROXY protocol接收必须配置 + }], + "routes": [{ + "match": [{ + "path": ["/HALdGZ9k"], //与VMess+WebSocket应用中path对应 + "header": { + "Connection": ["*Upgrade*"], + "Upgrade": ["websocket"] + } + }], + "handle": [{ + "handler": "reverse_proxy", + "upstreams": [{ + "dial": "127.0.0.1:2001" //转发给本机VMess+WebSocket监听端口 + }] + }] + }, + { + "match": [{ + "path": ["/SeuW56Es"] //与VLESS+H2C应用中path对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2005" //转发给本机VLESS+H2C监听端口 + }] + }] + }, + { + "match": [{ + "protocol": "grpc", + "path": ["/SALdGZ9k/*"] //与Shadowsocks+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2011" //转发给本机Shadowsocks+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "forward_proxy", + "auth_user_deprecated": "user", //NaiveProxy用户,修改为自己的。 + "auth_pass_deprecated": "pass", //NaiveProxy密码,修改为自己的。 + "hide_ip": true, + "hide_via": true, + "probe_resistance": {} + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接,修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["zh.xx.yy"] //限定域名连接,修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2"] //开启HTTP/1.1 server与HTTP/2 server支持(Caddy SNI分流不支持UDP转发) + } + } + }, + "tls": { + "certificates": { + "automate": ["zv.xx.yy","zt.xx.yy","zh.xx.yy","z1.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、从Let's Encrypt申请的普通TLS证书在‘/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zv.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,zv.xx.yy为域名,目录根据域名变化。 +//3、从ZeroSSL申请的普通TLS证书在‘/home/tls/certificates/acme.zerossl.com-v2-dv90/zv.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,zv.xx.yy为域名,目录根据域名变化。 +//4、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//5、本示例使用XTLS Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)、套CDN(zh.xx.yy)、非AES算法的密码套件配置(z1.xx.yy)来避免被封。 +//6、本示例使用不同域名来实现介绍中各应用,其办法如下: +//1)、VLESS+Vision+TLS仅使用zv.xx.yy域名。 +//2)、Trojan+TCP+TLS仅使用zt.xx.yy域名。 +//3)、VMess+WebSocket+TLS仅使用zh.xx.yy域名。 +//4)、VLESS+H2C+TLS仅使用z1.xx.yy域名。 +//5)、Shadowsocks+gRPC+TLS可使用zh.xx.yy域名或z1.xx.yy域名,推荐使用z1.xx.yy域名。 +//6)、NaiveProxy仅使用z1.xx.yy域名(使用HTTPS协议)。 diff --git a/Xray(E+F+B+D+G+A)+Caddy(N)/1_xray_config.json b/Xray(E+F+B+D+G+A)+Caddy(N)/1_xray_config.json new file mode 100644 index 00000000000..c5b8006a354 --- /dev/null +++ b/Xray(E+F+B+D+G+A)+Caddy(N)/1_xray_config.json @@ -0,0 +1,232 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 5443, //VLESS+Vision+TLS监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "5443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": 88, //h2与http/1.1回落端口(共用端口) + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。多级传递,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zv.xx.yy/zv.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zv.xx.yy/zv.xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "minVersion": "1.2" + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Caddy SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 6443, //Trojan+TCP+TLS监听端口 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy6443", //修改为自己密码 + "email": "6443@gmail.com" + } + ], + "fallbacks": [ + { + "dest": 88, //h2与http/1.1回落端口(共用端口) + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。与上一致,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zt.xx.yy/zt.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zt.xx.yy/zt.xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "minVersion": "1.2", + "maxVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" //非AES算法的密码套件 + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Caddy SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2001, //VMess+WebSocket监听端口 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2005, //VLESS+H2C监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "httpSettings": { + "path": "/SeuW56Es" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} +//备注: +//1、本配置支持XTLS Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)。 diff --git a/Xray(E+F+B+D+G+A)+Caddy(N)/2_caddy.json b/Xray(E+F+B+D+G+A)+Caddy(N)/2_caddy.json new file mode 100644 index 00000000000..52ef7cd70cf --- /dev/null +++ b/Xray(E+F+B+D+G+A)+Caddy(N)/2_caddy.json @@ -0,0 +1,242 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "storage": { + "module": "file_system", + "root": "/home/tls" //存放TLS证书的基本路径 + }, + "apps": { + "layer4": { + "servers": { + "sni": { + "listen": [":443"], + "routes": [{ + "match": [{ + "tls": { + "sni": ["zv.xx.yy"] //对应VLESS+Vision+TLS的域名(禁止以IP方式访问网站),修改为自己的。 + } + }], + "handle": [{ + "handler": "proxy", + "upstreams": [{ + "dial": ["unix/@vless"] //转给VLESS+Vision+TLS监听进程 + }], + "proxy_protocol": "v2" //启用PROXY protocol发送。v1或v2表示PROXY protocol版本,建议采用v2版。 + }] + }, + { + "match": [{ + "tls": { + "sni": ["zt.xx.yy"] //对应Trojan+TCP+TLS的域名(禁止以IP方式访问网站),修改为自己的。 + } + }], + "handle": [{ + "handler": "proxy", + "upstreams": [{ + "dial": ["unix/@trojan"] //转给Trojan+TCP+TLS监听进程 + }], + "proxy_protocol": "v2" //启用PROXY protocol发送。v1或v2表示PROXY protocol版本,建议采用v2版。 + }] + }, + { + "match": [{ + "tls": { + "sni": ["zh.xx.yy","z1.xx.yy"] //对应HTTPS server的域名(禁止以IP方式访问网站),修改为自己的。 + } + }], + "handle": [{ + "handler": "proxy", + "upstreams": [{ + "dial": ["unix/@https"] //转给HTTPS server监听进程 + }], + "proxy_protocol": "v2" //启用PROXY protocol发送。v1或v2表示PROXY protocol版本,建议采用v2版。 + }] + }] + } + } + }, + "http": { + "servers": { + "h1": { + "listen": [":80"], + "routes": [{ + "handle": [{ + "handler": "static_response", + "headers": { + "Location": ["https://{http.request.host}{http.request.uri}"] //HTTP自动跳转HTTPS,让网站看起来更真实。 + }, + "status_code": 301 + }] + }] + }, + "h1h2c": { + "listen": ["unix/@h1h2c"], //HTTP/1.1 server及H2C server监听进程 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }], + "routes": [{ + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "protocols": ["h1","h2c"] //开启HTTP/1.1 server与H2C server支持 + }, + "https": { + "listen": ["unix/@https"], //HTTPS server监听进程 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }, + { + "wrapper": "tls" //HTTPS server开启PROXY protocol接收必须配置 + }], + "routes": [{ + "match": [{ + "path": ["/HALdGZ9k"], //与VMess+WebSocket应用中path对应 + "header": { + "Connection": ["*Upgrade*"], + "Upgrade": ["websocket"] + } + }], + "handle": [{ + "handler": "reverse_proxy", + "upstreams": [{ + "dial": "unix/@vmessws" //转发给本机VMess+WebSocket监听进程 + }] + }] + }, + { + "match": [{ + "path": ["/SeuW56Es"] //与VLESS+H2C应用中path对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "unix/@vlessh2c" //转发给本机VLESS+H2C监听进程 + }] + }] + }, + { + "match": [{ + "protocol": "grpc", + "path": ["/SALdGZ9k/*"] //与Shadowsocks+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2011" //转发给本机Shadowsocks+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "forward_proxy", + "auth_user_deprecated": "user", //NaiveProxy用户,修改为自己的。 + "auth_pass_deprecated": "pass", //NaiveProxy密码,修改为自己的。 + "hide_ip": true, + "hide_via": true, + "probe_resistance": {} + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接,修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["zh.xx.yy"] //限定域名连接,修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2"] //开启HTTP/1.1 server与HTTP/2 server支持(Caddy SNI分流不支持UDP转发) + } + } + }, + "tls": { + "certificates": { + "automate": ["zv.xx.yy","zt.xx.yy","zh.xx.yy","z1.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、从Let's Encrypt申请的普通TLS证书在‘/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zv.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,zv.xx.yy为域名,目录根据域名变化。 +//3、从ZeroSSL申请的普通TLS证书在‘/home/tls/certificates/acme.zerossl.com-v2-dv90/zv.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,zv.xx.yy为域名,目录根据域名变化。 +//4、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//5、本示例使用XTLS Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)、套CDN(zh.xx.yy)、非AES算法的密码套件配置(z1.xx.yy)来避免被封。 +//6、本示例使用不同域名来实现介绍中各应用,其办法如下: +//1)、VLESS+Vision+TLS仅使用zv.xx.yy域名。 +//2)、Trojan+TCP+TLS仅使用zt.xx.yy域名。 +//3)、VMess+WebSocket+TLS仅使用zh.xx.yy域名。 +//4)、VLESS+H2C+TLS仅使用z1.xx.yy域名。 +//5)、Shadowsocks+gRPC+TLS可使用zh.xx.yy域名或z1.xx.yy域名,推荐使用z1.xx.yy域名。 +//6)、NaiveProxy仅使用z1.xx.yy域名(使用HTTPS协议)。 diff --git a/Xray(E+F+B+D+G+A)+Caddy(N)/2_xray_config.json b/Xray(E+F+B+D+G+A)+Caddy(N)/2_xray_config.json new file mode 100644 index 00000000000..00501063bf5 --- /dev/null +++ b/Xray(E+F+B+D+G+A)+Caddy(N)/2_xray_config.json @@ -0,0 +1,228 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "listen": "@vless", /VLESS+Vision+TLS监听进程 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "5443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": "@h1h2c", //h2与http/1.1回落进程(共用进程) + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。多级传递,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zv.xx.yy/zv.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zv.xx.yy/zv.xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "minVersion": "1.2" + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Caddy SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@trojan", //Trojan+TCP+TLS监听进程 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy6443", //修改为自己密码 + "email": "6443@gmail.com" + } + ], + "fallbacks": [ + { + "dest": "@h1h2c", //h2与http/1.1回落进程(共用进程) + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。与上一致,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zt.xx.yy/zt.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zt.xx.yy/zt.xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "minVersion": "1.2", + "maxVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" //非AES算法的密码套件 + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Caddy SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@vmessws", //VMess+WebSocket监听进程 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@vlessh2c", //VLESS+H2C监听进程 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "httpSettings": { + "path": "/SeuW56Es" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} +//备注: +//1、本配置支持XTLS Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)。 diff --git a/Xray(E+F+B+D+G+A)+Caddy(N)/README.md b/Xray(E+F+B+D+G+A)+Caddy(N)/README.md new file mode 100644 index 00000000000..b78e518bc14 --- /dev/null +++ b/Xray(E+F+B+D+G+A)+Caddy(N)/README.md @@ -0,0 +1,41 @@ +介绍: + +利用 Caddy 支持 SNI 分流特性,对 VLESS+Vision+TLS、Trojan+TCP+TLS、HTTPS server 进行 SNI 分流(四层转发),实现除 Xray 的 mKCP 应用外共用 443 端口。其中 Caddy 同时为 VLESS+Vision+TLS 与 Trojan+TCP+TLS 提供回落服务(WEB 服务),为 Xray 的 WebSocket、H2C、gRPC 提供反向代理,为 forwardproxy 插件提供正向代理,其应用如下: + +1、E=VLESS+Vision+TLS(回落/分流配置,TLS 由自己启用及处理。) + +2、F=Trojan+TCP+TLS(回落/分流配置,TLS 由自己启用及处理。) + +3、B=VMess+WebSocket+TLS(TLS 由 Caddy 提供及处理,不需配置。) + +4、D=VLESS+H2C+TLS(TLS 由 Caddy 提供及处理,不需配置。) + +5、G=Shadowsocks+gRPC+TLS(TLS 由 Caddy 提供及处理,不需配置。) + +6、A=VLESS+mKCP+seed + +7、N=NaiveProxy(基于 Caddy 的改进版 forwardproxy 插件实现,TLS 由 Caddy 提供及处理。) + +注意: + +1、Caddy 加 caddy-l4 插件定制编译的才可以实现 SNI 分流,目前仅支持使用 json 配置(不支持 Caddyfile 配置)。 + +2、Xray 版本不小于 v1.7.2 才完美支持 VLESS 协议的 XTLS Vision 应用。 + +3、Xray 的监听地址不支持 Shadowsocks 协议使用 UDS 监听。 + +4、Caddy 版本不小于 v2.6.0 才支持 H2C/gRPC proxy 的 UDS 转发。 + +5、Caddy 支持 HTTP/1.1 server 与 H2C server 共用一个端口或一个进程。 + +6、使用本人 Releases 中编译好的 Caddy 文件,可同时支持 SNI 分流、H2C server、H2C/gRPC proxy、NaiveProxy 等应用。 + +7、本示例 NaiveProxy 仅支持 HTTP/2 代理应用,即 HTTPS 协议传输。 + +8、本示例所需 TLS 证书由 Caddy(内置 ACME 客户端) 提供,实现 TLS 证书自动申请及更新。 + +9、配置1:使用 Local Loopback 连接,且启用了 PROXY protocol。配置2:使用 UDS 连接(对应 Shadowsocks+gRPC+TLS 除外),且启用了 PROXY protocol。 + +10、本示例 F 兼容原版 Trojan 的服务端应用,即可使用 Trojan 或 Trojan-Go 客户端连接。 + +11、若已有 Nginx 在用网站、或需要 NaiveProxy 支持 HTTP/3 代理应用,推荐采用 [Xray(E+F+B+D+G+A)+Caddy(N)+Nginx](https://github.com/lxhao61/integrated-examples/tree/main/Xray(E%2BF%2BB%2BD%2BG%2BA)%2BCaddy(N)%2BNginx) 示例。 diff --git a/Xray(E+F+B+D+G+A)+Caddy(N)/xray_SS-2022_config.json b/Xray(E+F+B+D+G+A)+Caddy(N)/xray_SS-2022_config.json new file mode 100644 index 00000000000..87803a31d96 --- /dev/null +++ b/Xray(E+F+B+D+G+A)+Caddy(N)/xray_SS-2022_config.json @@ -0,0 +1,46 @@ +//Shadowsocks-2022配置 +//原配置: +//........<省略>........ + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//以上配置修改为如下: +//单用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-chacha20-poly1305", //Shadowsocks-2022加密方法之一 + "password": "81qjRtwJZWx2gBphrLk18WZQ06B3Y2Vxlnqe903xXqU=", //修改为自己的密钥 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//多用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-aes-128-gcm", //Shadowsocks-2022加密方法之一 + "password": "rvQ6fK6Y4ckgFVslZlZUgQ==", //修改为自己的主项密钥 + "clients": [ + { + "password": "FPTg9fyNve167Fg8oPkFlQ==", //修改为自己的分项密钥 + "email": "2011@gmail.com" + }, + { + "password": "dkv04xu1f+UeM3mXpNJgVA==", //修改为自己的分项密钥 + "email": "2021@gmail.com" + } + ] + }, +//........<省略>........ +//备注: +//1、Xray从v1.5.9版开始支持Shadowsocks-2022。 +//2、密钥生成及长度 +//在服务器上直接使用‘openssl rand -base64 <长度> ’命令生成符合如下加密方法的对应密钥。 +// 加密方法 密钥长度 +//2022-blake3-aes-128-gcm 16 +//2022-blake3-aes-256-gcm 32 +//2022-blake3-chacha20-poly1305 32 +//3、多用户的客户端的密钥为主项密钥:分项密钥的组合,如rvQ6fK6Y4ckgFVslZlZUgQ==:FPTg9fyNve167Fg8oPkFlQ==。 diff --git a/Xray(E+F+B+G+A)+Nginx/1_nginx.conf b/Xray(E+F+B+G+A)+Nginx/1_nginx.conf new file mode 100644 index 00000000000..edfe2286bc8 --- /dev/null +++ b/Xray(E+F+B+G+A)+Nginx/1_nginx.conf @@ -0,0 +1,148 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +stream { + map $ssl_preread_server_name $backend_name { + zv.xx.yy vless; #zv.xx.yy为对应VLESS+Vision+TLS的域名,修改为自己的。 + zt.xx.yy trojan; #zt.xx.yy为对应Trojan+TCP+TLS的域名,修改为自己的。 + zh.xx.yy https; #zh.xx.yy为对应HTTPS server的域名,修改为自己的。 + } #禁止以IP方式访问网站 + upstream vless { + server 127.0.0.1:5443; #转给VLESS+Vision+TLS本地监听端口 + } + upstream trojan { + server 127.0.0.1:6443; #转给Trojan+TCP+TLS本地监听端口 + } + upstream https { + server 127.0.0.1:7443; #转给HTTPS server本地监听端口 + } + server { + listen 443; + listen [::]:443; #无IPv6,此项可以删除。 + ssl_preread on; + proxy_pass $backend_name; + proxy_protocol on; #启用PROXY protocol发送(全局模式) + } +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 127.0.0.1:81 proxy_protocol; #HTTP/1.1 server本地监听端口与开启PROXY protocol接收 + set_real_ip_from 127.0.0.1; + real_ip_header proxy_protocol; + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen 127.0.0.1:82 http2 proxy_protocol; #H2C server本地监听端口与开启PROXY protocol接收 + set_real_ip_from 127.0.0.1; + real_ip_header proxy_protocol; + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen 127.0.0.1:7443 ssl http2 proxy_protocol; #HTTPS server本地监听端口与开启PROXY protocol接收 + set_real_ip_from 127.0.0.1; + real_ip_header X-Forwarded-For; + + ssl_certificate /home/tls/zh.xx.yy/zh.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/zh.xx.yy/zh.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location = /HALdGZ9k { #与VMess+WebSocket应用中path对应 + if ($http_upgrade != "websocket") { + return 404; + } #WebSocket协商失败时返回404 + proxy_redirect off; + proxy_pass http://127.0.0.1:2001; #转发给本机VMess+WebSocket监听端口 + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例使用XTLS Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)、套CDN(zh.xx.yy)来避免被封。 +#2、本示例使用不同域名来实现介绍中各应用,其办法如下: +#1)、VLESS+Vision+TLS仅使用zv.xx.yy域名。 +#2)、Trojan+TCP+TLS仅使用zt.xx.yy域名。 +#3)、VMess+WebSocket+TLS仅使用zh.xx.yy域名。 +#4)、Shadowsocks+gRPC+TLS可使用zt.xx.yy域名或zh.xx.yy域名,推荐使用zt.xx.yy域名。 diff --git a/Xray(E+F+B+G+A)+Nginx/1_xray_config.json b/Xray(E+F+B+G+A)+Nginx/1_xray_config.json new file mode 100644 index 00000000000..0f4eaecac18 --- /dev/null +++ b/Xray(E+F+B+G+A)+Nginx/1_xray_config.json @@ -0,0 +1,214 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 5443, //VLESS+Vision+TLS监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "5443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "alpn": "h2", //h2回落匹配 + "dest": 82, //h2回落端口 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。多级传递,建议配置2。 + }, + { + "dest": 81, //http/1.1回落端口 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。与上一致,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/zv.xx.yy/zv.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/zv.xx.yy/zv.xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "minVersion": "1.2" + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Nginx SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 6443, //Trojan+TCP+TLS监听端口 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy6443", //修改为自己密码 + "email": "6443@gmail.com" + } + ], + "fallbacks": [ + { + "alpn": "h2", //h2回落匹配 + "dest": 82, //h2回落端口 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。与上一致,建议配置2。 + }, + { + "dest": 81, //http/1.1回落端口 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。与上一致,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/zt.xx.yy/zt.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/zt.xx.yy/zt.xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "minVersion": "1.2", + "maxVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256" //非AES算法的密码套件。若无RSA证书,可删除RSA算法的密码套件;无ECC证书,可删除ECDSA算法的密码套件。 + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Nginx SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2001, //VMess+WebSocket监听端口 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} +//备注: +//1、本配置支持XTLS Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)。 diff --git a/Xray(E+F+B+G+A)+Nginx/2_nginx.conf b/Xray(E+F+B+G+A)+Nginx/2_nginx.conf new file mode 100644 index 00000000000..4da7b2ef857 --- /dev/null +++ b/Xray(E+F+B+G+A)+Nginx/2_nginx.conf @@ -0,0 +1,148 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +stream { + map $ssl_preread_server_name $backend_name { + zv.xx.yy vless; #zv.xx.yy为对应VLESS+Vision+TLS的域名,修改为自己的。 + zt.xx.yy trojan; #zt.xx.yy为对应Trojan+TCP+TLS的域名,修改为自己的。 + zh.xx.yy https; #zh.xx.yy为对应HTTPS server的域名,修改为自己的。 + } #禁止以IP方式访问网站 + upstream vless { + server unix:/dev/shm/vless.sock; #转给VLESS+Vision+TLS监听进程 + } + upstream trojan { + server unix:/dev/shm/trojan.sock; #转给Trojan+TCP+TLS监听进程 + } + upstream https { + server unix:/dev/shm/https.sock; #转给HTTPS server监听进程 + } + server { + listen 443; + listen [::]:443; #无IPv6,此项可以删除。 + ssl_preread on; + proxy_pass $backend_name; + proxy_protocol on; #启用PROXY protocol发送(全局模式) + } +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen unix:/dev/shm/h1.sock proxy_protocol; #HTTP/1.1 server监听进程与开启PROXY protocol接收 + set_real_ip_from unix:; + real_ip_header proxy_protocol; + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen unix:/dev/shm/h2c.sock http2 proxy_protocol; #H2C server监听进程与开启PROXY protocol接收 + set_real_ip_from unix:; + real_ip_header proxy_protocol; + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen unix:/dev/shm/https.sock ssl http2 proxy_protocol; #HTTPS server监听进程与开启PROXY protocol接收 + set_real_ip_from unix:; + real_ip_header X-Forwarded-For; + + ssl_certificate /home/tls/zh.xx.yy/zh.xx.yy.crt; #换成自己的证书,绝对路径。 + ssl_certificate_key /home/tls/zh.xx.yy/zh.xx.yy.key; #换成自己的密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location = /HALdGZ9k { #与VMess+WebSocket应用中path对应 + if ($http_upgrade != "websocket") { + return 404; + } #WebSocket协商失败时返回404 + proxy_redirect off; + proxy_pass http://unix:/dev/shm/vmessws.sock; #转发给本机VMess+WebSocket监听进程 + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例使用XTLS Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)、套CDN(zh.xx.yy)来避免被封。 +#2、本示例使用不同域名来实现介绍中各应用,其办法如下: +#1)、VLESS+Vision+TLS仅使用zv.xx.yy域名。 +#2)、Trojan+TCP+TLS仅使用zt.xx.yy域名。 +#3)、VMess+WebSocket+TLS仅使用zh.xx.yy域名。 +#4)、Shadowsocks+gRPC+TLS可使用zt.xx.yy域名或zh.xx.yy域名,推荐使用zt.xx.yy域名。 diff --git a/Xray(E+F+B+G+A)+Nginx/2_xray_config.json b/Xray(E+F+B+G+A)+Nginx/2_xray_config.json new file mode 100644 index 00000000000..2eed2567fa1 --- /dev/null +++ b/Xray(E+F+B+G+A)+Nginx/2_xray_config.json @@ -0,0 +1,211 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "listen": "/dev/shm/vless.sock", //VLESS+Vision+TLS监听进程 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "5443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "alpn": "h2", //h2回落匹配 + "dest": "/dev/shm/h2c.sock", //h2回落进程 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。多级传递,建议配置2。 + }, + { + "dest": "/dev/shm/h1.sock", //http/1.1回落进程 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。与上一致,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/zv.xx.yy/zv.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/zv.xx.yy/zv.xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "minVersion": "1.2" + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Nginx SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "/dev/shm/trojan.sock", //Trojan+TCP+TLS监听进程 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy6443", //修改为自己密码 + "email": "6443@gmail.com" + } + ], + "fallbacks": [ + { + "alpn": "h2", //h2回落匹配 + "dest": "/dev/shm/h2c.sock", //h2回落进程 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。与上一致,建议配置2。 + }, + { + "dest": "/dev/shm/h1.sock", //http/1.1回落进程 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。与上一致,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/zt.xx.yy/zt.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/zt.xx.yy/zt.xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "minVersion": "1.2", + "maxVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256" //非AES算法的密码套件。若无RSA证书,可删除RSA算法的密码套件;无ECC证书,可删除ECDSA算法的密码套件。 + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Nginx SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "/dev/shm/vmessws.sock", //VMess+WebSocket监听进程 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} +//备注: +//1、本配置支持XTLS Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)。 diff --git a/Xray(E+F+B+G+A)+Nginx/README.md b/Xray(E+F+B+G+A)+Nginx/README.md new file mode 100644 index 00000000000..728282ff3ea --- /dev/null +++ b/Xray(E+F+B+G+A)+Nginx/README.md @@ -0,0 +1,33 @@ +介绍: + +利用 Nginx 支持 SNI 分流特性,对 VLESS+Vision+TLS、Trojan+TCP+TLS、HTTPS server 进行 SNI 分流(四层转发),实现除 Xray 的 mKCP 应用外共用 443 端口。其中 Nginx 同时为 VLESS+Vision+TLS 与 Trojan+TCP+TLS 提供回落服务(WEB 服务),为 Xray 的 WebSocket、gRPC 提供反向代理,其应用如下: + +1、E=VLESS+Vision+TLS(回落/分流配置,TLS 由自己启用及处理。) + +2、F=Trojan+TCP+TLS(回落/分流配置,TLS 由自己启用及处理。) + +3、B=VMess+WebSocket+TLS(TLS 由 Nginx 启用及处理,不需配置。) + +4、G=Shadowsocks+gRPC+TLS(TLS 由 Nginx 启用及处理,不需配置。) + +5、A=VLESS+mKCP+seed + +注意: + +1、Nginx 支持 SNI 分流需要 Nginx 包含 stream_core_module 和 stream_ssl_preread_module 模块。 + +2、Xray 的监听地址不支持 Shadowsocks 协议使用 UDS 监听。 + +3、Xray 版本不小于 v1.7.2 才完美支持 VLESS 协议的 XTLS Vision 应用。 + +4、Nginx 支持 H2C server、HTTP/2 server 及 gRPC proxy 需要 Nginx 包含 http_ssl_module 与 http_v2_module 模块及 OpenSSL 库。 + +5、Nginx 支持 H2C server,但不支持 HTTP/1.1 server 与 H2C server 共用一个端口或一个进程;故回落分成 http/1.1 回落与 h2 回落分别对应 Nginx 的 HTTP/1.1 server 与 H2C server。 + +6、Nginx 支持请求标头还原为真实客户端地址需要 Nginx 包含 http_realip_module 模块。 + +7、不要使用 ACME 客户端在采用本示例的服务器上以 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书,因 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书需监听 80 或 443 端口,从而与当前应用端口冲突。 + +8、配置1:使用 Local Loopback 连接,且启用了 PROXY protocol。配置2:使用 UDS 连接(对应 Shadowsocks+gRPC+TLS 除外),且启用了 PROXY protocol。 + +9、本示例 F 兼容原版 Trojan 的服务端应用,即可使用 Trojan 或 Trojan-Go 客户端连接。 diff --git a/Xray(E+F+B+G+A)+Nginx/xray_SS-2022_config.json b/Xray(E+F+B+G+A)+Nginx/xray_SS-2022_config.json new file mode 100644 index 00000000000..87803a31d96 --- /dev/null +++ b/Xray(E+F+B+G+A)+Nginx/xray_SS-2022_config.json @@ -0,0 +1,46 @@ +//Shadowsocks-2022配置 +//原配置: +//........<省略>........ + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//以上配置修改为如下: +//单用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-chacha20-poly1305", //Shadowsocks-2022加密方法之一 + "password": "81qjRtwJZWx2gBphrLk18WZQ06B3Y2Vxlnqe903xXqU=", //修改为自己的密钥 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//多用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-aes-128-gcm", //Shadowsocks-2022加密方法之一 + "password": "rvQ6fK6Y4ckgFVslZlZUgQ==", //修改为自己的主项密钥 + "clients": [ + { + "password": "FPTg9fyNve167Fg8oPkFlQ==", //修改为自己的分项密钥 + "email": "2011@gmail.com" + }, + { + "password": "dkv04xu1f+UeM3mXpNJgVA==", //修改为自己的分项密钥 + "email": "2021@gmail.com" + } + ] + }, +//........<省略>........ +//备注: +//1、Xray从v1.5.9版开始支持Shadowsocks-2022。 +//2、密钥生成及长度 +//在服务器上直接使用‘openssl rand -base64 <长度> ’命令生成符合如下加密方法的对应密钥。 +// 加密方法 密钥长度 +//2022-blake3-aes-128-gcm 16 +//2022-blake3-aes-256-gcm 32 +//2022-blake3-chacha20-poly1305 32 +//3、多用户的客户端的密钥为主项密钥:分项密钥的组合,如rvQ6fK6Y4ckgFVslZlZUgQ==:FPTg9fyNve167Fg8oPkFlQ==。 diff --git a/Xray(M+K)/1_xray_config.json b/Xray(M+K)/1_xray_config.json new file mode 100644 index 00000000000..47212d39474 --- /dev/null +++ b/Xray(M+K)/1_xray_config.json @@ -0,0 +1,102 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //VLESS+Vision+REALITY监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": 2005, //回落给VLESS+H2C监听端口 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给如下VLESS+H2C应用。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "reality", + "realitySettings": { + "show": false, //选填,若为true输出调试信息。 + "dest": "xx.yy:443", //转发给自己选定的目标网站。目标网站使用外部的一般为xx.yy:443,目标网站使用自己的一般直接端口或UDS。 + "xver": 0, //选填,默认关闭PROXY protocol发送。可填1或2开启PROXY protocol发送,1或2表示PROXY protocol版本。 + "serverNames": [ //必填,客户端可用的serverName列表,暂不支持*通配符。 + "xx.yy" //修改为目标网站证书对应的域名 + ], + "privateKey": "qZbyc2jAkWAhFEI7P5qhfBpI5yt4pgTS8-HgjpPjt8U", //修改为自己执行./xray x25519后生成的一对密钥中私钥。 + "shortIds": [ //必填,客户端可用的shortId列表,可用于区分不同的客户端。 + "" //若有此项,客户端shortId可为空。若不为空,可0到f(0123456789abcdef),长度为2的倍数,长度上限为16。 + ] + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2005, //VLESS+H2C监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "sockopt": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收VLESS+Vision+REALITY回落前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/Xray(M+K)/2_xray_config.json b/Xray(M+K)/2_xray_config.json new file mode 100644 index 00000000000..471e9daee91 --- /dev/null +++ b/Xray(M+K)/2_xray_config.json @@ -0,0 +1,101 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //VLESS+Vision+REALITY监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": "@vlessh2c", //回落给VLESS+H2C监听进程 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给如下VLESS+H2C应用。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "reality", + "realitySettings": { + "show": false, //选填,若为true输出调试信息。 + "dest": "xx.yy:443", //转发给自己选定的目标网站。目标网站使用外部的一般为xx.yy:443,目标网站使用自己的一般直接端口或UDS。 + "xver": 0, //选填,默认关闭PROXY protocol发送。可填1或2开启PROXY protocol发送,1或2表示PROXY protocol版本。 + "serverNames": [ //必填,客户端可用的serverName列表,暂不支持*通配符。 + "xx.yy" //修改为目标网站证书对应的域名 + ], + "privateKey": "qZbyc2jAkWAhFEI7P5qhfBpI5yt4pgTS8-HgjpPjt8U", //修改为自己执行./xray x25519后生成的一对密钥中私钥。 + "shortIds": [ //必填,客户端可用的shortId列表,可用于区分不同的客户端。 + "" //若有此项,客户端shortId可为空。若不为空,可0到f(0123456789abcdef),长度为2的倍数,长度上限为16。 + ] + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@vlessh2c", //VLESS+H2C监听进程 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "sockopt": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收VLESS+Vision+REALITY回落前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/Xray(M+K)/README.md b/Xray(M+K)/README.md new file mode 100644 index 00000000000..990782ca48c --- /dev/null +++ b/Xray(M+K)/README.md @@ -0,0 +1,17 @@ +介绍: + +Xray 前置(监听 443 端口),利用 VLESS+Vision+REALITY 回落(套娃) VLESS+H2C,实现 VLESS+Vision+REALITY 与 VLESS+H2C+REALITY 应用共用 443 端口,其应用如下: + +1、M=VLESS+Vision+REALITY(回落与转发配置,REALITY 由自己启用及处理。) + +2、K=VLESS+H2C+REALITY(REALITY 由 VLESS+Vision+REALITY 启用及处理,不需配置。) + +注意: + +1、Xray 版本不小于 v1.8.0 才支持 REALITY,其同步 uTLS(强制客户端必须使用指纹伪造)。 + +2、若目标网站使用外部的,其网站最低要求:国外网站、域名非跳转、支持 TLSv1.3 与 HTTP/2,是否符合要求可用 [SSL Server Test](https://www.ssllabs.com/ssltest/) 检查。 + +3、若目标网站使用自己的,其配置修改及网站配置可参考 [Xray(M+K+B+G+A)+Nginx](https://github.com/lxhao61/integrated-examples/tree/main/Xray(M%2BK%2BB%2BG%2BA)%2BNginx) 或 [Xray(M+K+B+G+A)+Caddy(N+T)](https://github.com/lxhao61/integrated-examples/tree/main/Xray(M%2BK%2BB%2BG%2BA)%2BCaddy(N%2BT)) 示例。 + +4、配置1:使用 Local Loopback 连接,且启用了 PROXY protocol。配置2:使用 UDS 连接,且启用了 PROXY protocol。 diff --git a/Xray(M+K+B+G+A)+Caddy(N+T)/1_caddy.json b/Xray(M+K+B+G+A)+Caddy(N+T)/1_caddy.json new file mode 100644 index 00000000000..e509c685e30 --- /dev/null +++ b/Xray(M+K+B+G+A)+Caddy(N+T)/1_caddy.json @@ -0,0 +1,174 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "apps": { + "http": { + "servers": { + "h1": { + "listen": [":80"], + "routes": [{ + "handle": [{ + "handler": "static_response", + "headers": { + "Location": ["https://{http.request.host}{http.request.uri}"] //HTTP自动跳转HTTPS,让网站看起来更真实。 + }, + "status_code": 301 + }] + }] + }, + "https": { + "listen": ["127.0.0.1:7443"], //HTTPS server本地监听端口 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }, + { + "wrapper": "tls" //HTTPS server开启PROXY protocol接收必须配置 + }, + { + "wrapper": "trojan" //caddy-trojan插件应用必须配置 + }], + "routes": [{ + "match": [{ + "path": ["/HALdGZ9k"], //与VMess+WebSocket应用中path对应 + "header": { + "Connection": ["*Upgrade*"], + "Upgrade": ["websocket"] + } + }], + "handle": [{ + "handler": "reverse_proxy", + "upstreams": [{ + "dial": "127.0.0.1:2001" //转发给本机VMess+WebSocket监听端口 + }] + }] + }, + { + "match": [{ + "protocol": "grpc", + "path": ["/SALdGZ9k/*"] //与Shadowsocks+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2011" //转发给本机Shadowsocks+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "forward_proxy", + "auth_user_deprecated": "user", //NaiveProxy用户,修改为自己的。 + "auth_pass_deprecated": "pass", //NaiveProxy密码,修改为自己的。 + "hide_ip": true, + "hide_via": true, + "probe_resistance": {} + }] + }, + { + "handle": [{ + "handler": "trojan", + "connect_method": true, + "websocket": true + }] + }, //此部分配置为caddy-trojan插件的WebSocket应用,若删除就仅支持Trojan应用。 + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z3.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["z1.xx.yy","z2.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2"] //开启HTTP/1.1 server与HTTP/2 server支持(REALITY转发不支持UDP透传) + } + } + }, + "trojan": { + "proxy": { + "proxy": "no_proxy" + }, + "upstream": { + "upstream": "memory" + }, + "users": ["diy443"] //修改为自己的密码。密码可多组("password"),用逗号隔开。 + }, + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy","z3.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//3、本示例使用REALITY Vision配置(z1.xx.yy)、套CDN(z2.xx.yy)、非AES算法的密码套件配置(z3.xx.yy)来避免被封。 +//4、本示例使用不同域名来实现介绍中各应用,其办法如下: +//1)、VLESS+Vision+REALITY仅使用z1.xx.yy域名。 +//2)、VLESS+H2C+REALITY仅使用z1.xx.yy域名。 +//3)、VMess+WebSocket+TLS仅使用z2.xx.yy域名。 +//4)、Shadowsocks+gRPC+TLS可使用z2.xx.yy域名或z3.xx.yy域名,推荐使用z3.xx.yy域名。 +//5)、NaiveProxy仅使用z3.xx.yy域名(使用HTTPS协议)。 +//6)、Trojan-Go使用Trojan应用时用z3.xx.yy域名,使用WebSocket应用时用z2.xx.yy域名。 diff --git a/Xray(M+K+B+G+A)+Caddy(N+T)/1_xray_config.json b/Xray(M+K+B+G+A)+Caddy(N+T)/1_xray_config.json new file mode 100644 index 00000000000..0be69f2cd48 --- /dev/null +++ b/Xray(M+K+B+G+A)+Caddy(N+T)/1_xray_config.json @@ -0,0 +1,183 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //VLESS+Vision+REALITY监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": 2005, //回落给VLESS+H2C监听端口 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给如下VLESS+H2C应用。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "reality", + "realitySettings": { + "show": false, //选填,若为true输出调试信息。 + "dest": 7443, //转发给自己的网站监听端口 + "xver": 1, //开启PROXY protocol发送,发送真实来源IP和端口给自己的网站。1或2表示PROXY protocol版本。 + "serverNames": [ //必填,客户端可用的serverName列表,暂不支持*通配符。 + "z1.xx.yy" //修改为自己的网站域名 + ], + "privateKey": "qZbyc2jAkWAhFEI7P5qhfBpI5yt4pgTS8-HgjpPjt8U", //修改为自己执行./xray x25519后生成的一对密钥中私钥。 + "shortIds": [ //必填,客户端可用的shortId列表,可用于区分不同的客户端。 + "" //若有此项,客户端shortId可为空。若不为空,可0到f(0123456789abcdef),长度为2的倍数,长度上限为16。 + ] + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2005, //VLESS+H2C监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "sockopt": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收VLESS+Vision+REALITY回落前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2001, //VMess+WebSocket监听端口 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/Xray(M+K+B+G+A)+Caddy(N+T)/2_caddy.json b/Xray(M+K+B+G+A)+Caddy(N+T)/2_caddy.json new file mode 100644 index 00000000000..a26b4c5cec3 --- /dev/null +++ b/Xray(M+K+B+G+A)+Caddy(N+T)/2_caddy.json @@ -0,0 +1,174 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "apps": { + "http": { + "servers": { + "h1": { + "listen": [":80"], + "routes": [{ + "handle": [{ + "handler": "static_response", + "headers": { + "Location": ["https://{http.request.host}{http.request.uri}"] //HTTP自动跳转HTTPS,让网站看起来更真实。 + }, + "status_code": 301 + }] + }] + }, + "https": { + "listen": ["unix/@https"], //HTTPS server监听进程 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }, + { + "wrapper": "tls" //HTTPS server开启PROXY protocol接收必须配置 + }, + { + "wrapper": "trojan" //caddy-trojan插件应用必须配置 + }], + "routes": [{ + "match": [{ + "path": ["/HALdGZ9k"], //与VMess+WebSocket应用中path对应 + "header": { + "Connection": ["*Upgrade*"], + "Upgrade": ["websocket"] + } + }], + "handle": [{ + "handler": "reverse_proxy", + "upstreams": [{ + "dial": "unix/@vmessws" //转发给本机VMess+WebSocket监听进程 + }] + }] + }, + { + "match": [{ + "protocol": "grpc", + "path": ["/SALdGZ9k/*"] //与Shadowsocks+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2011" //转发给本机Shadowsocks+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "forward_proxy", + "auth_user_deprecated": "user", //NaiveProxy用户,修改为自己的。 + "auth_pass_deprecated": "pass", //NaiveProxy密码,修改为自己的。 + "hide_ip": true, + "hide_via": true, + "probe_resistance": {} + }] + }, + { + "handle": [{ + "handler": "trojan", + "connect_method": true, + "websocket": true + }] + }, //此部分配置为caddy-trojan插件的WebSocket应用,若删除就仅支持Trojan应用。 + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["z2.xx.yy","h3.xx.yy"] //限定域名连接(禁止以IP方式访问网站),修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2"] //开启HTTP/1.1 server与HTTP/2 server支持(REALITY转发不支持UDP透传) + } + } + }, + "trojan": { + "proxy": { + "proxy": "no_proxy" + }, + "upstream": { + "upstream": "memory" + }, + "users": ["diy443"] //修改为自己的密码。密码可多组("password"),用逗号隔开。 + }, + "tls": { + "certificates": { + "automate": ["z1.xx.yy","z2.xx.yy","z3.xx.yy"] //自动化管理域名证书(包括获取、更新证书及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与下一致。 + }, + { + "module": "zerossl", + "email": "your@email.com" //修改为自己的电子邮箱(选配),与上一致。 + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//3、本示例使用REALITY Vision配置(z1.xx.yy)、套CDN(z2.xx.yy)、非AES算法的密码套件配置(z3.xx.yy)来避免被封。 +//4、本示例使用不同域名来实现介绍中各应用,其办法如下: +//1)、VLESS+Vision+REALITY仅使用z1.xx.yy域名。 +//2)、VLESS+H2C+REALITY仅使用z1.xx.yy域名。 +//3)、VMess+WebSocket+TLS仅使用z2.xx.yy域名。 +//4)、Shadowsocks+gRPC+TLS可使用z2.xx.yy域名或z3.xx.yy域名,推荐使用z3.xx.yy域名。 +//5)、NaiveProxy仅使用z3.xx.yy域名(使用HTTPS协议)。 +//6)、Trojan-Go使用Trojan应用时用z3.xx.yy域名,使用WebSocket应用时用z2.xx.yy域名。 diff --git a/Xray(M+K+B+G+A)+Caddy(N+T)/2_xray_config.json b/Xray(M+K+B+G+A)+Caddy(N+T)/2_xray_config.json new file mode 100644 index 00000000000..24400cf4c1c --- /dev/null +++ b/Xray(M+K+B+G+A)+Caddy(N+T)/2_xray_config.json @@ -0,0 +1,181 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //VLESS+Vision+REALITY监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": "@vlessh2c", //回落给VLESS+H2C监听进程 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给如下VLESS+H2C应用。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "reality", + "realitySettings": { + "show": false, //选填,若为true输出调试信息。 + "dest": "@https", //转发给自己的网站监听进程 + "xver": 1, //开启PROXY protocol发送,发送真实来源IP和端口给自己的网站。1或2表示PROXY protocol版本。 + "serverNames": [ //必填,客户端可用的serverName列表,暂不支持*通配符。 + "z1.xx.yy" //修改为自己的网站域名 + ], + "privateKey": "qZbyc2jAkWAhFEI7P5qhfBpI5yt4pgTS8-HgjpPjt8U", //修改为自己执行./xray x25519后生成的一对密钥中私钥。 + "shortIds": [ //必填,客户端可用的shortId列表,可用于区分不同的客户端。 + "" //若有此项,客户端shortId可为空。若不为空,可0到f(0123456789abcdef),长度为2的倍数,长度上限为16。 + ] + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@vlessh2c", //VLESS+H2C监听进程 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "sockopt": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收VLESS+Vision+REALITY回落前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@vmessws", //VMess+WebSocket监听进程 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/Xray(M+K+B+G+A)+Caddy(N+T)/README.md b/Xray(M+K+B+G+A)+Caddy(N+T)/README.md new file mode 100644 index 00000000000..617c5f4edb5 --- /dev/null +++ b/Xray(M+K+B+G+A)+Caddy(N+T)/README.md @@ -0,0 +1,35 @@ +介绍: + +Xray 前置(监听 443 端口),利用 VLESS+Vision+REALITY 支持回落与转发给自己网站,实现各应用共用 443 端口,其应用如下: + +1、M=VLESS+Vision+REALITY(回落与转发配置,REALITY 由自己启用及处理。) + +2、K=VLESS+H2C+REALITY(REALITY 由 VLESS+Vision+REALITY 启用及处理,不需配置。) + +3、B=VMess+WebSocket+TLS(TLS 由 Caddy 提供及处理,不需配置。) + +4、G=Shadowsocks+gRPC+TLS(TLS 由 Caddy 提供及处理,不需配置。) + +5、A=VLESS+mKCP+seed + +6、N=NaiveProxy(基于 Caddy 的改进版 forwardproxy 插件实现,TLS 由 Caddy 提供及处理,不需配置。) + +7、T=Trojan-Go(基于 Caddy 的 caddy-trojan 插件实现,TLS 由 Caddy 提供及处理,不需配置。) + +注意: + +1、Xray 版本不小于 v1.8.0 才支持 REALITY,其同步 uTLS(强制客户端必须使用指纹伪造)。 + +2、Xray 的监听地址不支持 Shadowsocks 协议使用 UDS 监听。 + +3、Caddy 版本不小于 v2.6.0 才支持 H2C/gRPC proxy 的 UDS 转发。 + +4、使用本人 Releases 中编译好的 Caddy 文件,可同时支持 H2C/gRPC proxy、NaiveProxy、Trojan-Go 及接收 PROXY protocol 等应用。 + +5、本示例 NaiveProxy 仅支持 HTTP/2 代理应用,即 HTTPS 协议传输。 + +6、本示例 Trojan-Go 仅推荐使用 Trojan 应用(不使用 WebSocket 应用):因为已有同类 WebSocket 应用,且其 WebSocket 应用不支持 WebSocket 0-RTT 与多路复用等;另外还可使用 [Trojan+WebSocket+TLS](https://github.com/lxhao61/integrated-examples/tree/main/V2Ray(Trojan%2BWebSocket)%2BCaddy%5CNginx) 应用替代,性能及兼容性更好。客户端推荐选择 Xray 客户端,支持使用指纹伪造。 + +7、本示例 Caddy 支持自动 HTTPS,即自动申请与更新 TLS 证书,自动 HTTP 重定向到 HTTPS。 + +8、配置1:使用 Local Loopback 连接,且启用了 PROXY protocol。配置2:使用 UDS 连接(对应 Shadowsocks+gRPC+TLS 除外),且启用了 PROXY protocol。 diff --git a/Xray(M+K+B+G+A)+Caddy(N+T)/xray_SS-2022_config.json b/Xray(M+K+B+G+A)+Caddy(N+T)/xray_SS-2022_config.json new file mode 100644 index 00000000000..87803a31d96 --- /dev/null +++ b/Xray(M+K+B+G+A)+Caddy(N+T)/xray_SS-2022_config.json @@ -0,0 +1,46 @@ +//Shadowsocks-2022配置 +//原配置: +//........<省略>........ + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//以上配置修改为如下: +//单用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-chacha20-poly1305", //Shadowsocks-2022加密方法之一 + "password": "81qjRtwJZWx2gBphrLk18WZQ06B3Y2Vxlnqe903xXqU=", //修改为自己的密钥 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//多用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-aes-128-gcm", //Shadowsocks-2022加密方法之一 + "password": "rvQ6fK6Y4ckgFVslZlZUgQ==", //修改为自己的主项密钥 + "clients": [ + { + "password": "FPTg9fyNve167Fg8oPkFlQ==", //修改为自己的分项密钥 + "email": "2011@gmail.com" + }, + { + "password": "dkv04xu1f+UeM3mXpNJgVA==", //修改为自己的分项密钥 + "email": "2021@gmail.com" + } + ] + }, +//........<省略>........ +//备注: +//1、Xray从v1.5.9版开始支持Shadowsocks-2022。 +//2、密钥生成及长度 +//在服务器上直接使用‘openssl rand -base64 <长度> ’命令生成符合如下加密方法的对应密钥。 +// 加密方法 密钥长度 +//2022-blake3-aes-128-gcm 16 +//2022-blake3-aes-256-gcm 32 +//2022-blake3-chacha20-poly1305 32 +//3、多用户的客户端的密钥为主项密钥:分项密钥的组合,如rvQ6fK6Y4ckgFVslZlZUgQ==:FPTg9fyNve167Fg8oPkFlQ==。 diff --git a/Xray(M+K+B+G+A)+Nginx/1_nginx.conf b/Xray(M+K+B+G+A)+Nginx/1_nginx.conf new file mode 100644 index 00000000000..7834c467a1a --- /dev/null +++ b/Xray(M+K+B+G+A)+Nginx/1_nginx.conf @@ -0,0 +1,95 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 127.0.0.1:7443 ssl http2 proxy_protocol default_server; + set_real_ip_from 127.0.0.1; + real_ip_header proxy_protocol; + ssl_protocols TLSv1.2 TLSv1.3; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen 127.0.0.1:7443 ssl http2 proxy_protocol; #HTTP/2 server本地监听端口与开启PROXY protocol接收 + set_real_ip_from 127.0.0.1; + real_ip_header X-Forwarded-For; + server_name z1.xx.yy z2.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/wildcard_.xx.yy/wildcard_.xx.yy.crt; #换成自己的通配符证书或SAN证书,绝对路径。 + ssl_certificate_key /home/tls/wildcard_.xx.yy/wildcard_.xx.yy.key; #换成自己的通配符密钥或SAN密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location = /HALdGZ9k { #与VMess+WebSocket应用中path对应 + if ($http_upgrade != "websocket") { + return 404; + } #WebSocket协商失败时返回404 + proxy_redirect off; + proxy_pass http://127.0.0.1:2001; #转发给本机VMess+WebSocket监听端口 + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例使用REALITY Vision配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 +#2、本示例使用不同域名来实现介绍中各应用,其办法如下: +#1)、VLESS+Vision+REALITY仅使用z1.xx.yy域名。 +#2)、VLESS+H2C+REALITY仅使用z1.xx.yy域名。 +#3)、VMess+WebSocket+TLS仅使用z2.xx.yy域名。 +#4)、Shadowsocks+gRPC+TLS仅使用z2.xx.yy域名。 diff --git a/Xray(M+K+B+G+A)+Nginx/1_xray_config.json b/Xray(M+K+B+G+A)+Nginx/1_xray_config.json new file mode 100644 index 00000000000..0be69f2cd48 --- /dev/null +++ b/Xray(M+K+B+G+A)+Nginx/1_xray_config.json @@ -0,0 +1,183 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //VLESS+Vision+REALITY监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": 2005, //回落给VLESS+H2C监听端口 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给如下VLESS+H2C应用。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "reality", + "realitySettings": { + "show": false, //选填,若为true输出调试信息。 + "dest": 7443, //转发给自己的网站监听端口 + "xver": 1, //开启PROXY protocol发送,发送真实来源IP和端口给自己的网站。1或2表示PROXY protocol版本。 + "serverNames": [ //必填,客户端可用的serverName列表,暂不支持*通配符。 + "z1.xx.yy" //修改为自己的网站域名 + ], + "privateKey": "qZbyc2jAkWAhFEI7P5qhfBpI5yt4pgTS8-HgjpPjt8U", //修改为自己执行./xray x25519后生成的一对密钥中私钥。 + "shortIds": [ //必填,客户端可用的shortId列表,可用于区分不同的客户端。 + "" //若有此项,客户端shortId可为空。若不为空,可0到f(0123456789abcdef),长度为2的倍数,长度上限为16。 + ] + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2005, //VLESS+H2C监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "sockopt": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收VLESS+Vision+REALITY回落前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2001, //VMess+WebSocket监听端口 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/Xray(M+K+B+G+A)+Nginx/2_nginx.conf b/Xray(M+K+B+G+A)+Nginx/2_nginx.conf new file mode 100644 index 00000000000..cf8b0e51f8a --- /dev/null +++ b/Xray(M+K+B+G+A)+Nginx/2_nginx.conf @@ -0,0 +1,95 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen unix:/dev/shm/http2.sock ssl http2 proxy_protocol default_server; + set_real_ip_from unix:; + real_ip_header proxy_protocol; + ssl_protocols TLSv1.2 TLSv1.3; + ssl_reject_handshake on; #版本不小于v1.19.4才支持 + } #限定域名访问(禁止以IP方式访问网站) + + server { + listen unix:/dev/shm/http2.sock ssl http2 proxy_protocol; #HTTP/2 server监听进程与开启PROXY protocol接收 + set_real_ip_from unix:; + real_ip_header X-Forwarded-For; + server_name z1.xx.yy z2.xx.yy; #修改为自己的域名 + + ssl_certificate /home/tls/wildcard_.xx.yy/wildcard_.xx.yy.crt; #换成自己的通配符证书或SAN证书,绝对路径。 + ssl_certificate_key /home/tls/wildcard_.xx.yy/wildcard_.xx.yy.key; #换成自己的通配符密钥或SAN密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location = /HALdGZ9k { #与VMess+WebSocket应用中path对应 + if ($http_upgrade != "websocket") { + return 404; + } #WebSocket协商失败时返回404 + proxy_redirect off; + proxy_pass http://unix:/dev/shm/vmessws.sock; #转发给本机VMess+WebSocket监听进程 + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例使用REALITY Vision配置(z1.xx.yy)、套CDN(z2.xx.yy)来避免被封。 +#2、本示例使用不同域名来实现介绍中各应用,其办法如下: +#1)、VLESS+Vision+REALITY仅使用z1.xx.yy域名。 +#2)、VLESS+H2C+REALITY仅使用z1.xx.yy域名。 +#3)、VMess+WebSocket+TLS仅使用z2.xx.yy域名。 +#4)、Shadowsocks+gRPC+TLS仅使用z2.xx.yy域名。 diff --git a/Xray(M+K+B+G+A)+Nginx/2_xray_config.json b/Xray(M+K+B+G+A)+Nginx/2_xray_config.json new file mode 100644 index 00000000000..a48b3b9f1cf --- /dev/null +++ b/Xray(M+K+B+G+A)+Nginx/2_xray_config.json @@ -0,0 +1,181 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //VLESS+Vision+REALITY监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": "@vlessh2c", //回落给VLESS+H2C监听进程 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给如下VLESS+H2C应用。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "reality", + "realitySettings": { + "show": false, //选填,若为true输出调试信息。 + "dest": "/dev/shm/http2.sock", //转发给自己的网站监听进程 + "xver": 1, //开启PROXY protocol发送,发送真实来源IP和端口给自己的网站。1或2表示PROXY protocol版本。 + "serverNames": [ //必填,客户端可用的serverName列表,暂不支持*通配符。 + "z1.xx.yy" //修改为自己的网站域名 + ], + "privateKey": "qZbyc2jAkWAhFEI7P5qhfBpI5yt4pgTS8-HgjpPjt8U", //修改为自己执行./xray x25519后生成的一对密钥中私钥。 + "shortIds": [ //必填,客户端可用的shortId列表,可用于区分不同的客户端。 + "" //若有此项,客户端shortId可为空。若不为空,可0到f(0123456789abcdef),长度为2的倍数,长度上限为16。 + ] + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@vlessh2c", //VLESS+H2C监听进程 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "sockopt": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收VLESS+Vision+REALITY回落前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "/dev/shm/vmessws.sock", //VMess+WebSocket监听进程 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/Xray(M+K+B+G+A)+Nginx/README.md b/Xray(M+K+B+G+A)+Nginx/README.md new file mode 100644 index 00000000000..94bb8886cac --- /dev/null +++ b/Xray(M+K+B+G+A)+Nginx/README.md @@ -0,0 +1,27 @@ +介绍: + +Xray 前置(监听 443 端口),利用 VLESS+Vision+REALITY 支持回落与转发给自己网站,实现各应用共用 443 端口,其应用如下: + +1、M=VLESS+Vision+REALITY(回落与转发配置,REALITY 由自己启用及处理。) + +2、K=VLESS+H2C+REALITY(REALITY 由 VLESS+Vision+REALITY 启用及处理,不需配置。) + +3、B=VMess+WebSocket+TLS(TLS 由 Nginx 启用及处理,不需配置。) + +4、G=Shadowsocks+gRPC+TLS(TLS 由 Nginx 启用及处理,不需配置。) + +5、A=VLESS+mKCP+seed + +注意: + +1、Xray 版本不小于 v1.8.0 才支持 REALITY,其同步 uTLS(强制客户端必须使用指纹伪造)。 + +2、Xray 的监听地址不支持 Shadowsocks 协议使用 UDS 监听。 + +3、Nginx 支持 HTTPS server、HTTP/2 server 及 WebSocket proxy、gRPC proxy 需要 Nginx 包含 http_ssl_module 与 http_v2_module 模块及 OpenSSL 库。 + +4、Nginx 支持请求标头还原为真实客户端地址需要 Nginx 包含 http_realip_module 模块。 + +5、不要使用 ACME 客户端在采用本示例的服务器上以 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书,因 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书需监听 80 或 443 端口,从而与当前应用端口冲突。 + +6、配置1:使用 Local Loopback 连接,且启用了 PROXY protocol。配置2:使用 UDS 连接(对应 Shadowsocks+gRPC+TLS 除外),且启用了 PROXY protocol。 diff --git a/Xray(M+K+B+G+A)+Nginx/xray_SS-2022_config.json b/Xray(M+K+B+G+A)+Nginx/xray_SS-2022_config.json new file mode 100644 index 00000000000..87803a31d96 --- /dev/null +++ b/Xray(M+K+B+G+A)+Nginx/xray_SS-2022_config.json @@ -0,0 +1,46 @@ +//Shadowsocks-2022配置 +//原配置: +//........<省略>........ + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//以上配置修改为如下: +//单用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-chacha20-poly1305", //Shadowsocks-2022加密方法之一 + "password": "81qjRtwJZWx2gBphrLk18WZQ06B3Y2Vxlnqe903xXqU=", //修改为自己的密钥 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//多用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-aes-128-gcm", //Shadowsocks-2022加密方法之一 + "password": "rvQ6fK6Y4ckgFVslZlZUgQ==", //修改为自己的主项密钥 + "clients": [ + { + "password": "FPTg9fyNve167Fg8oPkFlQ==", //修改为自己的分项密钥 + "email": "2011@gmail.com" + }, + { + "password": "dkv04xu1f+UeM3mXpNJgVA==", //修改为自己的分项密钥 + "email": "2021@gmail.com" + } + ] + }, +//........<省略>........ +//备注: +//1、Xray从v1.5.9版开始支持Shadowsocks-2022。 +//2、密钥生成及长度 +//在服务器上直接使用‘openssl rand -base64 <长度> ’命令生成符合如下加密方法的对应密钥。 +// 加密方法 密钥长度 +//2022-blake3-aes-128-gcm 16 +//2022-blake3-aes-256-gcm 32 +//2022-blake3-chacha20-poly1305 32 +//3、多用户的客户端的密钥为主项密钥:分项密钥的组合,如rvQ6fK6Y4ckgFVslZlZUgQ==:FPTg9fyNve167Fg8oPkFlQ==。 diff --git a/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/1_caddy.json b/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/1_caddy.json new file mode 100644 index 00000000000..e89326074fd --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/1_caddy.json @@ -0,0 +1,171 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "storage": { + "module": "file_system", + "root": "/home/tls" //存放TLS证书的基本路径 + }, + "apps": { + "http": { + "servers": { + "h1": { + "listen": [":80"], + "routes": [{ + "handle": [{ + "handler": "static_response", + "headers": { + "Location": ["https://{http.request.host}{http.request.uri}"] //HTTP自动跳转HTTPS,让网站看起来更真实。 + }, + "status_code": 301 + }] + }] + }, + "h1h2c": { + "listen": ["127.0.0.1:88"], //HTTP/1.1 server及H2C server本地监听端口 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }], + "routes": [{ + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "protocols": ["h1","h2c"] //开启HTTP/1.1 server与H2C server支持 + }, + "https": { + "listen": ["127.0.0.1:7443"], //HTTPS server本地监听端口 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }, + { + "wrapper": "tls" //HTTPS server开启PROXY protocol接收必须配置 + }], + "routes": [{ + "match": [{ + "path": ["/HALdGZ9k"], //与VMess+WebSocket应用中path对应 + "header": { + "Connection": ["*Upgrade*"], + "Upgrade": ["websocket"] + } + }], + "handle": [{ + "handler": "reverse_proxy", + "upstreams": [{ + "dial": "127.0.0.1:2001" //转发给本机VMess+WebSocket监听端口 + }] + }] + }, + { + "match": [{ + "protocol": "grpc", + "path": ["/SALdGZ9k/*"] //与Shadowsocks+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2011" //转发给本机Shadowsocks+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "forward_proxy", + "auth_user_deprecated": "user", //NaiveProxy用户,修改为自己的。 + "auth_pass_deprecated": "pass", //NaiveProxy密码,修改为自己的。 + "hide_ip": true, + "hide_via": true, + "probe_resistance": {} + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接,修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["zv.xx.yy","zh.xx.yy","h3.xx.yy"] //限定域名连接,修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2","h3"] //默认配置 + } + } + }, + "tls": { + "certificates": { + "automate": ["zv.xx.yy","zt.xx.yy","zh.xx.yy","z1.xx.yy","h3.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、从Let's Encrypt申请的普通TLS证书在‘/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zv.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,zv.xx.yy为域名,目录根据域名变化。 +//3、从ZeroSSL申请的普通TLS证书在‘/home/tls/certificates/acme.zerossl.com-v2-dv90/zv.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,zv.xx.yy为域名,目录根据域名变化。 +//4、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//5、本配置支持套CDN(zh.xx.yy)、非AES算法的密码套件配置(z1.xx.yy)及HTTP/3代理(h3.xx.yy)。 diff --git a/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/1_nginx.conf b/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/1_nginx.conf new file mode 100644 index 00000000000..0c316059b4d --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/1_nginx.conf @@ -0,0 +1,53 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +stream { + map $ssl_preread_server_name $backend_name { + zv.xx.yy vless; #zv.xx.yy为对应VLESS+Vision+REALITY的域名,修改为自己的。 + zt.xx.yy trojan; #zt.xx.yy为对应Trojan+TCP+TLS的域名,修改为自己的。 + zh.xx.yy https; #zh.xx.yy为对应HTTPS server的域名,修改为自己的。 + z1.xx.yy https; #z1.xx.yy为对应HTTPS server的域名,修改为自己的。 + h3.xx.yy https; #h3.xx.yy为对应HTTPS server的域名,修改为自己的。 + } #禁止以IP方式访问网站 + upstream vless { + server 127.0.0.1:5443; #转给VLESS+Vision+REALITY本地监听端口 + } + upstream trojan { + server 127.0.0.1:6443; #转给Trojan+TCP+TLS本地监听端口 + } + upstream https { + server 127.0.0.1:7443; #转给HTTPS server本地监听端口 + } + server { + listen 443; + listen [::]:443; #无IPv6,此项可以删除。 + ssl_preread on; + proxy_pass $backend_name; + proxy_protocol on; #启用PROXY protocol发送(全局模式) + } + + server { + listen 443 udp; + listen [::]:443 udp; #无IPv6,此项可以删除。 + proxy_pass 127.0.0.1:7443; #转给HTTPS server本地监听端口 + } #定向UDP转发配置 +} +#备注: +#1、本示例使用REALITY Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)、套CDN(zh.xx.yy)、非AES算法的密码套件配置(z1.xx.yy)来避免被封。 +#2、本示例使用不同域名来实现介绍中各应用,其办法如下: +#1)、VLESS+Vision+REALITY仅使用zv.xx.yy域名。 +#2)、VLESS+H2C+REALITY仅使用zv.xx.yy域名。 +#3)、Trojan+TCP+TLS仅使用zt.xx.yy域名。 +#4)、VMess+WebSocket+TLS仅使用zh.xx.yy域名。 +#5)、Shadowsocks+gRPC+TLS可使用zh.xx.yy域名或z1.xx.yy域名,推荐使用z1.xx.yy域名。 +#6)、NaiveProxy使用HTTPS协议时用z1.xx.yy域名,使用QUIC协议时用h3.xx.yy域名。 +#3、本示例无Nginx在用网站应用,如需要请自行增加。调整请参考Xray(M+K+F+B+G+A)+Nginx示例中Nginx配置。 diff --git a/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/1_xray_config.json b/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/1_xray_config.json new file mode 100644 index 00000000000..03d8a31fd03 --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/1_xray_config.json @@ -0,0 +1,234 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 5443, //VLESS+Vision+REALITY监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "5443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": 2005, //回落给VLESS+H2C监听端口 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给如下VLESS+H2C应用。1或2表示PROXY protocol版本。多级传递,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "reality", + "realitySettings": { + "show": false, //选填,若为true输出调试信息。 + "dest": 7443, //转发给自己的网站监听端口 + "xver": 2, //开启PROXY protocol发送,发送真实来源IP和端口给自己的网站。1或2表示PROXY protocol版本。 + "serverNames": [ //必填,客户端可用的serverName列表,暂不支持*通配符。 + "zv.xx.yy" //修改为自己的网站域名 + ], + "privateKey": "qZbyc2jAkWAhFEI7P5qhfBpI5yt4pgTS8-HgjpPjt8U", //修改为自己执行./xray x25519后生成的一对密钥中私钥。 + "shortIds": [ //必填,客户端可用的shortId列表,可用于区分不同的客户端。 + "" //若有此项,客户端shortId可为空。若不为空,可0到f(0123456789abcdef),长度为2的倍数,长度上限为16。 + ] + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Caddy SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2005, //VLESS+H2C监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "sockopt": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收VLESS+Vision+REALITY回落前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 6443, //Trojan+TCP+TLS监听端口 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy6443", //修改为自己密码 + "email": "6443@gmail.com" + } + ], + "fallbacks": [ + { + "dest": 88, //h2与http/1.1回落端口(共用端口) + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。与上一致,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zt.xx.yy/zt.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zt.xx.yy/zt.xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "minVersion": "1.2", + "maxVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" //非AES算法的密码套件 + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Caddy SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2001, //VMess+WebSocket监听端口 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} +//备注: +//1、本配置支持REALITY Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)。 diff --git a/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/2_caddy.json b/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/2_caddy.json new file mode 100644 index 00000000000..57c69a27517 --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/2_caddy.json @@ -0,0 +1,171 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "storage": { + "module": "file_system", + "root": "/home/tls" //存放TLS证书的基本路径 + }, + "apps": { + "http": { + "servers": { + "h1": { + "listen": [":80"], + "routes": [{ + "handle": [{ + "handler": "static_response", + "headers": { + "Location": ["https://{http.request.host}{http.request.uri}"] //HTTP自动跳转HTTPS,让网站看起来更真实。 + }, + "status_code": 301 + }] + }] + }, + "h1h2c": { + "listen": ["unix/@h1h2c"], //HTTP/1.1 server及H2C server监听进程 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }], + "routes": [{ + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "protocols": ["h1","h2c"] //开启HTTP/1.1 server与H2C server支持 + }, + "https": { + "listen": ["127.0.0.1:7443"], //HTTPS server本地监听端口 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }, + { + "wrapper": "tls" //HTTPS server开启PROXY protocol接收必须配置 + }], + "routes": [{ + "match": [{ + "path": ["/HALdGZ9k"], //与VMess+WebSocket应用中path对应 + "header": { + "Connection": ["*Upgrade*"], + "Upgrade": ["websocket"] + } + }], + "handle": [{ + "handler": "reverse_proxy", + "upstreams": [{ + "dial": "unix/@vmessws" //转发给本机VMess+WebSocket监听进程 + }] + }] + }, + { + "match": [{ + "protocol": "grpc", + "path": ["/SALdGZ9k/*"] //与Shadowsocks+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2011" //转发给本机Shadowsocks+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "forward_proxy", + "auth_user_deprecated": "user", //NaiveProxy用户,修改为自己的。 + "auth_pass_deprecated": "pass", //NaiveProxy密码,修改为自己的。 + "hide_ip": true, + "hide_via": true, + "probe_resistance": {} + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接,修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["zv.xx.yy","zh.xx.yy","h3.xx.yy"] //限定域名连接,修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2","h3"] //默认配置 + } + } + }, + "tls": { + "certificates": { + "automate": ["zv.xx.yy","zt.xx.yy","zh.xx.yy","z1.xx.yy","h3.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、从Let's Encrypt申请的普通TLS证书在‘/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zv.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,zv.xx.yy为域名,目录根据域名变化。 +//3、从ZeroSSL申请的普通TLS证书在‘/home/tls/certificates/acme.zerossl.com-v2-dv90/zv.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,zv.xx.yy为域名,目录根据域名变化。 +//4、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//5、本配置支持套CDN(zh.xx.yy)、非AES算法的密码套件配置(z1.xx.yy)及HTTP/3代理(h3.xx.yy)。 diff --git a/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/2_nginx.conf b/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/2_nginx.conf new file mode 100644 index 00000000000..723ae54aeec --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/2_nginx.conf @@ -0,0 +1,53 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +stream { + map $ssl_preread_server_name $backend_name { + zv.xx.yy vless; #zv.xx.yy为对应VLESS+Vision+REALITY的域名,修改为自己的。 + zt.xx.yy trojan; #zt.xx.yy为对应Trojan+TCP+TLS的域名,修改为自己的。 + zh.xx.yy https; #zh.xx.yy为对应HTTPS server的域名,修改为自己的。 + z1.xx.yy https; #z1.xx.yy为对应HTTPS server的域名,修改为自己的。 + h3.xx.yy https; #h3.xx.yy为对应HTTPS server的域名,修改为自己的。 + } #禁止以IP方式访问网站 + upstream vless { + server unix:/dev/shm/vless.sock; #转给VLESS+Vision+REALITY监听进程 + } + upstream trojan { + server unix:/dev/shm/trojan.sock; #转给Trojan+TCP+TLS监听进程 + } + upstream https { + server 127.0.0.1:7443; #转给HTTPS server本地监听端口 + } + server { + listen 443; + listen [::]:443; #无IPv6,此项可以删除。 + ssl_preread on; + proxy_pass $backend_name; + proxy_protocol on; #启用PROXY protocol发送(全局模式) + } + + server { + listen 443 udp; + listen [::]:443 udp; #无IPv6,此项可以删除。 + proxy_pass 127.0.0.1:7443; #转给HTTPS server本地监听端口 + } #定向UDP转发配置 +} +#备注: +#1、本示例使用REALITY Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)、套CDN(zh.xx.yy)、非AES算法的密码套件配置(z1.xx.yy)来避免被封。 +#2、本示例使用不同域名来实现介绍中各应用,其办法如下: +#1)、VLESS+Vision+REALITY仅使用zv.xx.yy域名。 +#2)、VLESS+H2C+REALITY仅使用zv.xx.yy域名。 +#3)、Trojan+TCP+TLS仅使用zt.xx.yy域名。 +#4)、VMess+WebSocket+TLS仅使用zh.xx.yy域名。 +#5)、Shadowsocks+gRPC+TLS可使用zh.xx.yy域名或z1.xx.yy域名,推荐使用z1.xx.yy域名。 +#6)、NaiveProxy使用HTTPS协议时用z1.xx.yy域名,使用QUIC协议时用h3.xx.yy域名。 +#3、本示例无Nginx在用网站应用,如需要请自行增加。调整请参考Xray(M+K+F+B+G+A)+Nginx示例中Nginx配置。 diff --git a/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/2_xray_config.json b/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/2_xray_config.json new file mode 100644 index 00000000000..787d2a78492 --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/2_xray_config.json @@ -0,0 +1,230 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "listen": "/dev/shm/vless.sock", //VLESS+Vision+REALITY监听进程 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "5443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": "@vlessh2c", //回落给VLESS+H2C监听进程 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给如下VLESS+H2C应用。1或2表示PROXY protocol版本。多级传递,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "reality", + "realitySettings": { + "show": false, //选填,若为true输出调试信息。 + "dest": 7443, //转发给自己的网站监听端口 + "xver": 2, //开启PROXY protocol发送,发送真实来源IP和端口给自己的网站。1或2表示PROXY protocol版本。 + "serverNames": [ //必填,客户端可用的serverName列表,暂不支持*通配符。 + "zv.xx.yy" //修改为自己的网站域名 + ], + "privateKey": "qZbyc2jAkWAhFEI7P5qhfBpI5yt4pgTS8-HgjpPjt8U", //修改为自己执行./xray x25519后生成的一对密钥中私钥。 + "shortIds": [ //必填,客户端可用的shortId列表,可用于区分不同的客户端。 + "" //若有此项,客户端shortId可为空。若不为空,可0到f(0123456789abcdef),长度为2的倍数,长度上限为16。 + ] + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Caddy SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@vlessh2c", //VLESS+H2C监听进程 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "sockopt": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收VLESS+Vision+REALITY回落前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "/dev/shm/trojan.sock", //Trojan+TCP+TLS监听进程 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy6443", //修改为自己密码 + "email": "6443@gmail.com" + } + ], + "fallbacks": [ + { + "dest": "@h1h2c", //h2与http/1.1回落进程(共用进程) + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。与上一致,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zt.xx.yy/zt.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zt.xx.yy/zt.xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "minVersion": "1.2", + "maxVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" //非AES算法的密码套件 + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Caddy SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@vmessws", //VMess+WebSocket监听进程 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} +//备注: +//1、本配置支持REALITY Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)。 diff --git a/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/README.md b/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/README.md new file mode 100644 index 00000000000..7446f7f0281 --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/README.md @@ -0,0 +1,41 @@ +介绍: + +利用 Nginx 支持 SNI 分流特性,对 VLESS+Vision+REALITY、Trojan+TCP+TLS、HTTPS server 进行 SNI 分流(四层转发),实现除 Xray 的 mKCP 应用外共用 443 端口。其中 VLESS+Vision+REALITY 回落(套娃) VLESS+H2C;Caddy 为 Trojan+TCP+TLS 提供回落服务(WEB 服务),为 Xray 的 WebSocket 与 gRPC 提供反向代理,为 forwardproxy 插件提供正向代理,其应用如下: + +1、M=VLESS+Vision+REALITY(回落与转发配置,REALITY 由自己启用及处理。) + +2、K=VLESS+H2C+REALITY(REALITY 由 VLESS+Vision+REALITY 启用及处理,不需配置。) + +3、F=Trojan+TCP+TLS(回落/分流配置,TLS 由自己启用及处理。) + +4、B=VMess+WebSocket+TLS(TLS 由 Caddy 提供及处理,不需配置。) + +5、G=Shadowsocks+gRPC+TLS(TLS 由 Caddy 提供及处理,不需配置。) + +6、A=VLESS+mKCP+seed + +7、N=NaiveProxy(基于 Caddy 的改进版 forwardproxy 插件实现,TLS 由 Caddy 提供及处理,不需配置。) + +注意: + +1、Nginx 支持 SNI 分流需要 Nginx 包含 stream_core_module 和 stream_ssl_preread_module 模块。 + +2、Xray 版本不小于 v1.8.0 才支持 REALITY,其同步 uTLS(强制客户端必须使用指纹伪造)。 + +3、Xray 的监听地址不支持 Shadowsocks 协议使用 UDS 监听。 + +4、Caddy 版本不小于 v2.6.0 才支持 H2C/gRPC proxy 的 UDS 转发。 + +5、Caddy 支持 HTTP/1.1 server 与 H2C server 共用一个端口或一个进程。 + +6、使用本人 Releases 中编译好的 Caddy 文件,可同时支持 H2C server、H2C/gRPC proxy、NaiveProxy 等应用。 + +7、本示例 NaiveProxy 除了支持 HTTP/2 代理应用,还同时支持 HTTP/3 代理应用,即 QUIC 协议传输。若 NaiveProxy 使用 HTTP/3 代理应用,建议增加 [UDP 接收缓冲区大小](https://github.com/lucas-clemente/quic-go/wiki/UDP-Receive-Buffer-Size)。 + +8、本示例所需 TLS 证书由 Caddy(内置 ACME 客户端) 提供,实现 TLS 证书自动申请及更新。 + +9、配置1:使用 Local Loopback 连接,且启用了 PROXY protocol。配置2:使用 UDS 连接(对应 HTTPS server、Shadowsocks+gRPC+TLS 除外),且启用了 PROXY protocol。 + +10、本示例 F 兼容原版 Trojan 的服务端应用,即可使用 Trojan 或 Trojan-Go 客户端连接。 + +11、若仅实现科学上网、且不需要 NaiveProxy 支持 HTTP/3 代理应用,推荐采用 [Xray(M+K+F+B+G+A)+Caddy(N)](https://github.com/lxhao61/integrated-examples/tree/main/Xray(M%2BK%2BF%2BB%2BG%2BA)%2BCaddy(N)) 示例。 diff --git a/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/xray_SS-2022_config.json b/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/xray_SS-2022_config.json new file mode 100644 index 00000000000..87803a31d96 --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Caddy(N)+Nginx/xray_SS-2022_config.json @@ -0,0 +1,46 @@ +//Shadowsocks-2022配置 +//原配置: +//........<省略>........ + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//以上配置修改为如下: +//单用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-chacha20-poly1305", //Shadowsocks-2022加密方法之一 + "password": "81qjRtwJZWx2gBphrLk18WZQ06B3Y2Vxlnqe903xXqU=", //修改为自己的密钥 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//多用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-aes-128-gcm", //Shadowsocks-2022加密方法之一 + "password": "rvQ6fK6Y4ckgFVslZlZUgQ==", //修改为自己的主项密钥 + "clients": [ + { + "password": "FPTg9fyNve167Fg8oPkFlQ==", //修改为自己的分项密钥 + "email": "2011@gmail.com" + }, + { + "password": "dkv04xu1f+UeM3mXpNJgVA==", //修改为自己的分项密钥 + "email": "2021@gmail.com" + } + ] + }, +//........<省略>........ +//备注: +//1、Xray从v1.5.9版开始支持Shadowsocks-2022。 +//2、密钥生成及长度 +//在服务器上直接使用‘openssl rand -base64 <长度> ’命令生成符合如下加密方法的对应密钥。 +// 加密方法 密钥长度 +//2022-blake3-aes-128-gcm 16 +//2022-blake3-aes-256-gcm 32 +//2022-blake3-chacha20-poly1305 32 +//3、多用户的客户端的密钥为主项密钥:分项密钥的组合,如rvQ6fK6Y4ckgFVslZlZUgQ==:FPTg9fyNve167Fg8oPkFlQ==。 diff --git a/Xray(M+K+F+B+G+A)+Caddy(N)/1_caddy.json b/Xray(M+K+F+B+G+A)+Caddy(N)/1_caddy.json new file mode 100644 index 00000000000..862272e836b --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Caddy(N)/1_caddy.json @@ -0,0 +1,227 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "storage": { + "module": "file_system", + "root": "/home/tls" //存放TLS证书的基本路径 + }, + "apps": { + "layer4": { + "servers": { + "sni": { + "listen": [":443"], + "routes": [{ + "match": [{ + "tls": { + "sni": ["zv.xx.yy"] //对应VLESS+Vision+REALITY的域名(禁止以IP方式访问网站),修改为自己的。 + } + }], + "handle": [{ + "handler": "proxy", + "upstreams": [{ + "dial": ["127.0.0.1:5443"] //转给VLESS+Vision+REALITY本地监听端口 + }], + "proxy_protocol": "v2" //启用PROXY protocol发送。v1或v2表示PROXY protocol版本,建议采用v2版。 + }] + }, + { + "match": [{ + "tls": { + "sni": ["zt.xx.yy"] //对应Trojan+TCP+TLS的域名(禁止以IP方式访问网站),修改为自己的。 + } + }], + "handle": [{ + "handler": "proxy", + "upstreams": [{ + "dial": ["127.0.0.1:6443"] //转给Trojan+TCP+TLS本地监听端口 + }], + "proxy_protocol": "v2" //启用PROXY protocol发送。v1或v2表示PROXY protocol版本,建议采用v2版。 + }] + }, + { + "match": [{ + "tls": { + "sni": ["zh.xx.yy","z1.xx.yy"] //对应HTTPS server的域名(禁止以IP方式访问网站),修改为自己的。 + } + }], + "handle": [{ + "handler": "proxy", + "upstreams": [{ + "dial": ["127.0.0.1:7443"] //转给HTTPS server本地监听端口 + }], + "proxy_protocol": "v2" //启用PROXY protocol发送。v1或v2表示PROXY protocol版本,建议采用v2版。 + }] + }] + } + } + }, + "http": { + "servers": { + "h1": { + "listen": [":80"], + "routes": [{ + "handle": [{ + "handler": "static_response", + "headers": { + "Location": ["https://{http.request.host}{http.request.uri}"] //HTTP自动跳转HTTPS,让网站看起来更真实。 + }, + "status_code": 301 + }] + }] + }, + "h1h2c": { + "listen": ["127.0.0.1:88"], //HTTP/1.1 server及H2C server本地监听端口 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }], + "routes": [{ + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "protocols": ["h1","h2c"] //开启HTTP/1.1 server与H2C server支持 + }, + "https": { + "listen": ["127.0.0.1:7443"], //HTTPS server本地监听端口 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }, + { + "wrapper": "tls" //HTTPS server开启PROXY protocol接收必须配置 + }], + "routes": [{ + "match": [{ + "path": ["/HALdGZ9k"], //与VMess+WebSocket应用中path对应 + "header": { + "Connection": ["*Upgrade*"], + "Upgrade": ["websocket"] + } + }], + "handle": [{ + "handler": "reverse_proxy", + "upstreams": [{ + "dial": "127.0.0.1:2001" //转发给本机VMess+WebSocket监听端口 + }] + }] + }, + { + "match": [{ + "protocol": "grpc", + "path": ["/SALdGZ9k/*"] //与Shadowsocks+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2011" //转发给本机Shadowsocks+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "forward_proxy", + "auth_user_deprecated": "user", //NaiveProxy用户,修改为自己的。 + "auth_pass_deprecated": "pass", //NaiveProxy密码,修改为自己的。 + "hide_ip": true, + "hide_via": true, + "probe_resistance": {} + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接,修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["zv.xx.yy","zh.xx.yy"] //限定域名连接,修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2"] //开启HTTP/1.1 server与HTTP/2 server支持(Caddy SNI分流不支持UDP转发) + } + } + }, + "tls": { + "certificates": { + "automate": ["zv.xx.yy","zt.xx.yy","zh.xx.yy","z1.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、从Let's Encrypt申请的普通TLS证书在‘/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zv.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,zv.xx.yy为域名,目录根据域名变化。 +//3、从ZeroSSL申请的普通TLS证书在‘/home/tls/certificates/acme.zerossl.com-v2-dv90/zv.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,zv.xx.yy为域名,目录根据域名变化。 +//4、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//5、本示例使用REALITY Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)、套CDN(zh.xx.yy)、非AES算法的密码套件配置(z1.xx.yy)来避免被封。 +//6、本示例使用不同域名来实现介绍中各应用,其办法如下: +//1)、VLESS+Vision+REALITY仅使用zv.xx.yy域名。 +//2)、VLESS+H2C+REALITY仅使用zv.xx.yy域名。 +//3)、Trojan+TCP+TLS仅使用zt.xx.yy域名。 +//4)、VMess+WebSocket+TLS仅使用zh.xx.yy域名。 +//5)、Shadowsocks+gRPC+TLS可使用zh.xx.yy域名或z1.xx.yy域名,推荐使用z1.xx.yy域名。 +//6)、NaiveProxy仅使用z1.xx.yy域名(使用HTTPS协议)。 diff --git a/Xray(M+K+F+B+G+A)+Caddy(N)/1_xray_config.json b/Xray(M+K+F+B+G+A)+Caddy(N)/1_xray_config.json new file mode 100644 index 00000000000..03d8a31fd03 --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Caddy(N)/1_xray_config.json @@ -0,0 +1,234 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 5443, //VLESS+Vision+REALITY监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "5443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": 2005, //回落给VLESS+H2C监听端口 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给如下VLESS+H2C应用。1或2表示PROXY protocol版本。多级传递,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "reality", + "realitySettings": { + "show": false, //选填,若为true输出调试信息。 + "dest": 7443, //转发给自己的网站监听端口 + "xver": 2, //开启PROXY protocol发送,发送真实来源IP和端口给自己的网站。1或2表示PROXY protocol版本。 + "serverNames": [ //必填,客户端可用的serverName列表,暂不支持*通配符。 + "zv.xx.yy" //修改为自己的网站域名 + ], + "privateKey": "qZbyc2jAkWAhFEI7P5qhfBpI5yt4pgTS8-HgjpPjt8U", //修改为自己执行./xray x25519后生成的一对密钥中私钥。 + "shortIds": [ //必填,客户端可用的shortId列表,可用于区分不同的客户端。 + "" //若有此项,客户端shortId可为空。若不为空,可0到f(0123456789abcdef),长度为2的倍数,长度上限为16。 + ] + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Caddy SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2005, //VLESS+H2C监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "sockopt": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收VLESS+Vision+REALITY回落前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 6443, //Trojan+TCP+TLS监听端口 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy6443", //修改为自己密码 + "email": "6443@gmail.com" + } + ], + "fallbacks": [ + { + "dest": 88, //h2与http/1.1回落端口(共用端口) + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。与上一致,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zt.xx.yy/zt.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zt.xx.yy/zt.xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "minVersion": "1.2", + "maxVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" //非AES算法的密码套件 + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Caddy SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2001, //VMess+WebSocket监听端口 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} +//备注: +//1、本配置支持REALITY Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)。 diff --git a/Xray(M+K+F+B+G+A)+Caddy(N)/2_caddy.json b/Xray(M+K+F+B+G+A)+Caddy(N)/2_caddy.json new file mode 100644 index 00000000000..78b4e350761 --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Caddy(N)/2_caddy.json @@ -0,0 +1,227 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "storage": { + "module": "file_system", + "root": "/home/tls" //存放TLS证书的基本路径 + }, + "apps": { + "layer4": { + "servers": { + "sni": { + "listen": [":443"], + "routes": [{ + "match": [{ + "tls": { + "sni": ["zv.xx.yy"] //对应VLESS+Vision+REALITY的域名(禁止以IP方式访问网站),修改为自己的。 + } + }], + "handle": [{ + "handler": "proxy", + "upstreams": [{ + "dial": ["unix/@vless"] //转给VLESS+Vision+REALITY监听进程 + }], + "proxy_protocol": "v2" //启用PROXY protocol发送。v1或v2表示PROXY protocol版本,建议采用v2版。 + }] + }, + { + "match": [{ + "tls": { + "sni": ["zt.xx.yy"] //对应Trojan+TCP+TLS的域名(禁止以IP方式访问网站),修改为自己的。 + } + }], + "handle": [{ + "handler": "proxy", + "upstreams": [{ + "dial": ["unix/@trojan"] //转给Trojan+TCP+TLS监听进程 + }], + "proxy_protocol": "v2" //启用PROXY protocol发送。v1或v2表示PROXY protocol版本,建议采用v2版。 + }] + }, + { + "match": [{ + "tls": { + "sni": ["zh.xx.yy","z1.xx.yy"] //对应HTTPS server的域名(禁止以IP方式访问网站),修改为自己的。 + } + }], + "handle": [{ + "handler": "proxy", + "upstreams": [{ + "dial": ["unix/@https"] //转给HTTPS server监听进程 + }], + "proxy_protocol": "v2" //启用PROXY protocol发送。v1或v2表示PROXY protocol版本,建议采用v2版。 + }] + }] + } + } + }, + "http": { + "servers": { + "h1": { + "listen": [":80"], + "routes": [{ + "handle": [{ + "handler": "static_response", + "headers": { + "Location": ["https://{http.request.host}{http.request.uri}"] //HTTP自动跳转HTTPS,让网站看起来更真实。 + }, + "status_code": 301 + }] + }] + }, + "h1h2c": { + "listen": ["unix/@h1h2c"], //HTTP/1.1 server及H2C server监听进程 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }], + "routes": [{ + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "protocols": ["h1","h2c"] //开启HTTP/1.1 server与H2C server支持 + }, + "https": { + "listen": ["unix/@https"], //HTTPS server监听进程 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }, + { + "wrapper": "tls" //HTTPS server开启PROXY protocol接收必须配置 + }], + "routes": [{ + "match": [{ + "path": ["/HALdGZ9k"], //与VMess+WebSocket应用中path对应 + "header": { + "Connection": ["*Upgrade*"], + "Upgrade": ["websocket"] + } + }], + "handle": [{ + "handler": "reverse_proxy", + "upstreams": [{ + "dial": "unix/@vmessws" //转发给本机VMess+WebSocket监听进程 + }] + }] + }, + { + "match": [{ + "protocol": "grpc", + "path": ["/SALdGZ9k/*"] //与Shadowsocks+gRPC应用中serviceName对应 + }], + "handle": [{ + "handler": "reverse_proxy", + "transport": { + "protocol": "http", + "versions": ["h2c","2"] + }, + "upstreams": [{ + "dial": "127.0.0.1:2011" //转发给本机Shadowsocks+gRPC监听端口 + }], + "headers": { + "request": { + "set": { + "X-Real-IP": ["{http.vars.client_ip}"] + } + } + } + }] + }, + { + "handle": [{ + "handler": "forward_proxy", + "auth_user_deprecated": "user", //NaiveProxy用户,修改为自己的。 + "auth_pass_deprecated": "pass", //NaiveProxy密码,修改为自己的。 + "hide_ip": true, + "hide_via": true, + "probe_resistance": {} + }] + }, + { + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "tls_connection_policies": [{ + "match": { + "sni": ["z1.xx.yy"] //限定域名连接,修改为自己的域名。 + }, + "protocol_min": "tls1.2", + "protocol_max": "tls1.2", + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], //非AES算法的密码套件 + "curves": ["secp521r1","secp384r1","secp256r1"] + }, + { + "match": { + "sni": ["zv.xx.yy","zh.xx.yy"] //限定域名连接,修改为自己的域名。 + }, + "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256","TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384","TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256"], + "curves": ["x25519","secp521r1","secp384r1","secp256r1"] + }], + "trusted_proxies": { + "source": "cloudflare", //cloudflare为使用cloudflare ips,由caddy-cloudflare-ip插件提供。 + "interval": "12h", + "timeout": "15s" + }, //配置可信CDN服务器的IP范围,以实现套CDN的应用的访问IP还原为客户端原始IP。若使用其它非Cloudflare CDN,需自己调整trusted_proxies的配置参数。(选配,套CDN配置。) + "protocols": ["h1","h2"] //开启HTTP/1.1 server与HTTP/2 server支持(Caddy SNI分流不支持UDP转发) + } + } + }, + "tls": { + "certificates": { + "automate": ["zv.xx.yy","zt.xx.yy","zh.xx.yy","z1.xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } + } +} +//备注: +//1、申请免费TLS证书的域名不要超过五个,否则影响TLS证书的更新。 +//2、从Let's Encrypt申请的普通TLS证书在‘/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zv.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,zv.xx.yy为域名,目录根据域名变化。 +//3、从ZeroSSL申请的普通TLS证书在‘/home/tls/certificates/acme.zerossl.com-v2-dv90/zv.xx.yy’目录中。/home/tls为存放TLS证书的基本路径,zv.xx.yy为域名,目录根据域名变化。 +//4、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 +//5、本示例使用REALITY Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)、套CDN(zh.xx.yy)、非AES算法的密码套件配置(z1.xx.yy)来避免被封。 +//6、本示例使用不同域名来实现介绍中各应用,其办法如下: +//1)、VLESS+Vision+REALITY仅使用zv.xx.yy域名。 +//2)、VLESS+H2C+REALITY仅使用zv.xx.yy域名。 +//3)、Trojan+TCP+TLS仅使用zt.xx.yy域名。 +//4)、VMess+WebSocket+TLS仅使用zh.xx.yy域名。 +//5)、Shadowsocks+gRPC+TLS可使用zh.xx.yy域名或z1.xx.yy域名,推荐使用z1.xx.yy域名。 +//6)、NaiveProxy仅使用z1.xx.yy域名(使用HTTPS协议)。 diff --git a/Xray(M+K+F+B+G+A)+Caddy(N)/2_xray_config.json b/Xray(M+K+F+B+G+A)+Caddy(N)/2_xray_config.json new file mode 100644 index 00000000000..745d9862c95 --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Caddy(N)/2_xray_config.json @@ -0,0 +1,230 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "listen": "@vless", //VLESS+Vision+REALITY监听进程 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "5443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": "@vlessh2c", //回落给VLESS+H2C监听进程 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给如下VLESS+H2C应用。1或2表示PROXY protocol版本。多级传递,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "reality", + "realitySettings": { + "show": false, //选填,若为true输出调试信息。 + "dest": "@https", //转发给自己的网站监听进程 + "xver": 2, //开启PROXY protocol发送,发送真实来源IP和端口给自己的网站。1或2表示PROXY protocol版本。 + "serverNames": [ //必填,客户端可用的serverName列表,暂不支持*通配符。 + "zv.xx.yy" //修改为自己的网站域名 + ], + "privateKey": "qZbyc2jAkWAhFEI7P5qhfBpI5yt4pgTS8-HgjpPjt8U", //修改为自己执行./xray x25519后生成的一对密钥中私钥。 + "shortIds": [ //必填,客户端可用的shortId列表,可用于区分不同的客户端。 + "" //若有此项,客户端shortId可为空。若不为空,可0到f(0123456789abcdef),长度为2的倍数,长度上限为16。 + ] + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Caddy SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@vlessh2c", //VLESS+H2C监听进程 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "sockopt": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收VLESS+Vision+REALITY回落前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@trojan", //Trojan+TCP+TLS监听进程 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy6443", //修改为自己密码 + "email": "6443@gmail.com" + } + ], + "fallbacks": [ + { + "dest": "@h1h2c", //h2与http/1.1回落进程(共用进程) + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。与上一致,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zt.xx.yy/zt.xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/zt.xx.yy/zt.xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "minVersion": "1.2", + "maxVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" //非AES算法的密码套件 + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Caddy SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@vmessws", //VMess+WebSocket监听进程 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} +//备注: +//1、本配置支持REALITY Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)。 diff --git a/Xray(M+K+F+B+G+A)+Caddy(N)/README.md b/Xray(M+K+F+B+G+A)+Caddy(N)/README.md new file mode 100644 index 00000000000..7b7339c31c1 --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Caddy(N)/README.md @@ -0,0 +1,41 @@ +介绍: + +利用 Caddy 支持 SNI 分流特性,对 VLESS+Vision+REALITY、Trojan+TCP+TLS、HTTPS server 进行 SNI 分流(四层转发),实现除 Xray 的 mKCP 应用外共用 443 端口。其中 VLESS+Vision+REALITY 回落(套娃) VLESS+H2C;Caddy 同时为 Trojan+TCP+TLS 提供回落服务(WEB 服务),为 Xray 的 WebSocket 与 gRPC 提供反向代理,为 forwardproxy 插件提供正向代理,其应用如下: + +1、M=VLESS+Vision+REALITY(回落与转发配置,REALITY 由自己启用及处理。) + +2、K=VLESS+H2C+REALITY(REALITY 由 VLESS+Vision+REALITY 启用及处理,不需配置。) + +3、F=Trojan+TCP+TLS(回落/分流配置,TLS 由自己启用及处理。) + +4、B=VMess+WebSocket+TLS(TLS 由 Caddy 提供及处理,不需配置。) + +5、G=Shadowsocks+gRPC+TLS(TLS 由 Caddy 提供及处理,不需配置。) + +6、A=VLESS+mKCP+seed + +7、N=NaiveProxy(基于 Caddy 的改进版 forwardproxy 插件实现,TLS 由 Caddy 提供及处理,不需配置。) + +注意: + +1、Caddy 加 caddy-l4 插件定制编译的才可以实现 SNI 分流,目前仅支持使用 json 配置(不支持 Caddyfile 配置)。 + +2、Xray 版本不小于 v1.8.0 才支持 REALITY,其同步 uTLS(强制客户端必须使用指纹伪造)。 + +3、Xray 的监听地址不支持 Shadowsocks 协议使用 UDS 监听。 + +4、Caddy 版本不小于 v2.6.0 才支持 H2C/gRPC proxy 的 UDS 转发。 + +5、Caddy 支持 HTTP/1.1 server 与 H2C server 共用一个端口或一个进程。 + +6、使用本人 Releases 中编译好的 Caddy 文件,可同时支持SNI 分流、H2C server、H2C/gRPC proxy、NaiveProxy 等应用。 + +7、本示例 NaiveProxy 仅支持 HTTP/2 代理应用,即 HTTPS 协议传输。 + +8、本示例所需 TLS 证书由 Caddy(内置 ACME 客户端) 提供,实现 TLS 证书自动申请及更新。 + +9、配置1:使用 Local Loopback 连接,且启用了 PROXY protocol。配置2:使用 UDS 连接(对应 Shadowsocks+gRPC+TLS 除外),且启用了 PROXY protocol。 + +10、本示例 F 兼容原版 Trojan 的服务端应用,即可使用 Trojan 或 Trojan-Go 客户端连接。 + +11、若已有 Nginx 在用网站、或需要 NaiveProxy 支持 HTTP/3 代理应用,推荐采用 [Xray(M+K+F+B+G+A)+Caddy(N)+Nginx](https://github.com/lxhao61/integrated-examples/tree/main/Xray(M%2BK%2BF%2BB%2BG%2BA)%2BCaddy(N)%2BNginx) 示例。 diff --git a/Xray(M+K+F+B+G+A)+Caddy(N)/xray_SS-2022_config.json b/Xray(M+K+F+B+G+A)+Caddy(N)/xray_SS-2022_config.json new file mode 100644 index 00000000000..87803a31d96 --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Caddy(N)/xray_SS-2022_config.json @@ -0,0 +1,46 @@ +//Shadowsocks-2022配置 +//原配置: +//........<省略>........ + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//以上配置修改为如下: +//单用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-chacha20-poly1305", //Shadowsocks-2022加密方法之一 + "password": "81qjRtwJZWx2gBphrLk18WZQ06B3Y2Vxlnqe903xXqU=", //修改为自己的密钥 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//多用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-aes-128-gcm", //Shadowsocks-2022加密方法之一 + "password": "rvQ6fK6Y4ckgFVslZlZUgQ==", //修改为自己的主项密钥 + "clients": [ + { + "password": "FPTg9fyNve167Fg8oPkFlQ==", //修改为自己的分项密钥 + "email": "2011@gmail.com" + }, + { + "password": "dkv04xu1f+UeM3mXpNJgVA==", //修改为自己的分项密钥 + "email": "2021@gmail.com" + } + ] + }, +//........<省略>........ +//备注: +//1、Xray从v1.5.9版开始支持Shadowsocks-2022。 +//2、密钥生成及长度 +//在服务器上直接使用‘openssl rand -base64 <长度> ’命令生成符合如下加密方法的对应密钥。 +// 加密方法 密钥长度 +//2022-blake3-aes-128-gcm 16 +//2022-blake3-aes-256-gcm 32 +//2022-blake3-chacha20-poly1305 32 +//3、多用户的客户端的密钥为主项密钥:分项密钥的组合,如rvQ6fK6Y4ckgFVslZlZUgQ==:FPTg9fyNve167Fg8oPkFlQ==。 diff --git a/Xray(M+K+F+B+G+A)+Nginx/1_nginx.conf b/Xray(M+K+F+B+G+A)+Nginx/1_nginx.conf new file mode 100644 index 00000000000..742503d7dc2 --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Nginx/1_nginx.conf @@ -0,0 +1,148 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +stream { + map $ssl_preread_server_name $backend_name { + zv.xx.yy vless; #zv.xx.yy为对应VLESS+Vision+REALITY的域名,修改为自己的。 + zt.xx.yy trojan; #zt.xx.yy为对应Trojan+TCP+TLS的域名,修改为自己的。 + zh.xx.yy https; #zh.xx.yy为对应HTTPS server的域名,修改为自己的。 + } #禁止以IP方式访问网站 + upstream vless { + server 127.0.0.1:5443; #转给VLESS+Vision+REALITY本地监听端口 + } + upstream trojan { + server 127.0.0.1:6443; #转给Trojan+TCP+TLS本地监听端口 + } + upstream https { + server 127.0.0.1:7443; #转给HTTPS server本地监听端口 + } + server { + listen 443; + listen [::]:443; #无IPv6,此项可以删除。 + ssl_preread on; + proxy_pass $backend_name; + proxy_protocol on; #启用PROXY protocol发送(全局模式) + } +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 127.0.0.1:81 proxy_protocol; #HTTP/1.1 server本地监听端口与开启PROXY protocol接收 + set_real_ip_from 127.0.0.1; + real_ip_header proxy_protocol; + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen 127.0.0.1:82 http2 proxy_protocol; #H2C server本地监听端口与开启PROXY protocol接收 + set_real_ip_from 127.0.0.1; + real_ip_header proxy_protocol; + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen 127.0.0.1:7443 ssl http2 proxy_protocol; #HTTPS server本地监听端口与开启PROXY protocol接收 + set_real_ip_from 127.0.0.1; + real_ip_header X-Forwarded-For; + + ssl_certificate /home/tls/wildcard_.xx.yy/wildcard_.xx.yy.crt; #换成自己的通配符证书或SAN证书,绝对路径。 + ssl_certificate_key /home/tls/wildcard_.xx.yy/wildcard_.xx.yy.key; #换成自己的通配符密钥或SAN密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location = /HALdGZ9k { #与VMess+WebSocket应用中path对应 + if ($http_upgrade != "websocket") { + return 404; + } #WebSocket协商失败时返回404 + proxy_redirect off; + proxy_pass http://127.0.0.1:2001; #转发给本机VMess+WebSocket监听端口 + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例使用REALITY Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)、套CDN(zh.xx.yy)来避免被封。 +#2、本示例使用不同域名来实现介绍中各应用,其办法如下: +#1)、VLESS+Vision+REALITY仅使用zv.xx.yy域名。 +#2)、VLESS+H2C+REALITY仅使用zv.xx.yy域名。 +#3)、Trojan+TCP+TLS仅使用zt.xx.yy域名。 +#4)、VMess+WebSocket+TLS仅使用zh.xx.yy域名。 +#5)、Shadowsocks+gRPC+TLS可使用zt.xx.yy域名或zh.xx.yy域名,推荐使用zt.xx.yy域名。 diff --git a/Xray(M+K+F+B+G+A)+Nginx/1_xray_config.json b/Xray(M+K+F+B+G+A)+Nginx/1_xray_config.json new file mode 100644 index 00000000000..65877a888b7 --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Nginx/1_xray_config.json @@ -0,0 +1,239 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 5443, //VLESS+Vision+REALITY监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "5443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": 2005, //回落给VLESS+H2C监听端口 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给如下VLESS+H2C应用。1或2表示PROXY protocol版本。多级传递,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "reality", + "realitySettings": { + "show": false, //选填,若为true输出调试信息。 + "dest": 7443, //转发给自己的网站监听端口 + "xver": 2, //开启PROXY protocol发送,发送真实来源IP和端口给自己的网站。1或2表示PROXY protocol版本。 + "serverNames": [ //必填,客户端可用的serverName列表,暂不支持*通配符。 + "zv.xx.yy" //修改为自己的网站域名 + ], + "privateKey": "qZbyc2jAkWAhFEI7P5qhfBpI5yt4pgTS8-HgjpPjt8U", //修改为自己执行./xray x25519后生成的一对密钥中私钥。 + "shortIds": [ //必填,客户端可用的shortId列表,可用于区分不同的客户端。 + "" //若有此项,客户端shortId可为空。若不为空,可0到f(0123456789abcdef),长度为2的倍数,长度上限为16。 + ] + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Nginx SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2005, //VLESS+H2C监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "sockopt": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收VLESS+Vision+REALITY回落前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 6443, //Trojan+TCP+TLS监听端口 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy6443", //修改为自己密码 + "email": "6443@gmail.com" + } + ], + "fallbacks": [ + { + "alpn": "h2", //h2回落匹配 + "dest": 82, //h2回落端口 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。与上一致,建议配置2。 + }, + { + "dest": 81, //http/1.1回落端口 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。与上一致,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/wildcard_.xx.yy/wildcard_.xx.yy.crt", //换成自己的通配符证书或SAN证书,绝对路径。 + "keyFile": "/home/tls/wildcard_.xx.yy/wildcard_.xx.yy.key" //换成自己的通配符密钥或SAN密钥,绝对路径。 + } + ], + "minVersion": "1.2", + "maxVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256" //非AES算法的密码套件。若无RSA证书,可删除RSA算法的密码套件;无ECC证书,可删除ECDSA算法的密码套件。 + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Nginx SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2001, //VMess+WebSocket监听端口 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} +//备注: +//1、本配置支持REALITY Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)。 diff --git a/Xray(M+K+F+B+G+A)+Nginx/2_nginx.conf b/Xray(M+K+F+B+G+A)+Nginx/2_nginx.conf new file mode 100644 index 00000000000..01592986474 --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Nginx/2_nginx.conf @@ -0,0 +1,148 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +stream { + map $ssl_preread_server_name $backend_name { + zv.xx.yy vless; #zv.xx.yy为对应VLESS+Vision+REALITY的域名,修改为自己的。 + zt.xx.yy trojan; #zt.xx.yy为对应Trojan+TCP+TLS的域名,修改为自己的。 + zh.xx.yy https; #zh.xx.yy为对应HTTPS server的域名,修改为自己的。 + } #禁止以IP方式访问网站 + upstream vless { + server unix:/dev/shm/vless.sock; #转给VLESS+Vision+REALITY监听进程 + } + upstream trojan { + server unix:/dev/shm/trojan.sock; #转给Trojan+TCP+TLS监听进程 + } + upstream https { + server unix:/dev/shm/https.sock; #转给HTTPS server监听进程 + } + server { + listen 443; + listen [::]:443; #无IPv6,此项可以删除。 + ssl_preread on; + proxy_pass $backend_name; + proxy_protocol on; #启用PROXY protocol发送(全局模式) + } +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen unix:/dev/shm/h1.sock proxy_protocol; #HTTP/1.1 server监听进程与开启PROXY protocol接收 + set_real_ip_from unix:; + real_ip_header proxy_protocol; + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen unix:/dev/shm/h2c.sock http2 proxy_protocol; #H2C server监听进程与开启PROXY protocol接收 + set_real_ip_from unix:; + real_ip_header proxy_protocol; + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header Host $host; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } + + server { + listen unix:/dev/shm/https.sock ssl http2 proxy_protocol; #HTTPS server监听进程与开启PROXY protocol接收 + set_real_ip_from unix:; + real_ip_header X-Forwarded-For; + + ssl_certificate /home/tls/wildcard_.xx.yy/wildcard_.xx.yy.crt; #换成自己的通配符证书或SAN证书,绝对路径。 + ssl_certificate_key /home/tls/wildcard_.xx.yy/wildcard_.xx.yy.key; #换成自己的通配符密钥或SAN密钥,绝对路径。 + + ssl_protocols TLSv1.2 TLSv1.3; #TLSv1.3需使用版本不小于1.1.1的OpenSSL库编译才支持 + ssl_prefer_server_ciphers on; #优先使用服务端的密码套件(对如下TLSv1.2协议的密码套件有效) + ssl_ciphers ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-GCM-SHA256; #若证书为RSA证书,所有ECDSA改为RSA。 + ssl_ecdh_curve secp521r1:secp384r1:secp256r1:x25519; #指定的参数需使用版本不小于3.0.0的OpenSSL库编译才支持 + + location = /HALdGZ9k { #与VMess+WebSocket应用中path对应 + if ($http_upgrade != "websocket") { + return 404; + } #WebSocket协商失败时返回404 + proxy_redirect off; + proxy_pass http://unix:/dev/shm/vmessws.sock; #转发给本机VMess+WebSocket监听进程 + proxy_http_version 1.1; + proxy_set_header Upgrade $http_upgrade; + proxy_set_header Connection "upgrade"; + proxy_set_header Host $host; + proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; + } + + location /SALdGZ9k { #与Shadowsocks+gRPC应用中serviceName对应 + if ($request_method != "POST") { + return 404; + } #POST协商失败时返回404 + client_body_buffer_size 1m; + client_body_timeout 1h; + client_max_body_size 0; + grpc_pass grpc://127.0.0.1:2011; #转发给本机Shadowsocks+gRPC监听端口 + grpc_read_timeout 1h; + grpc_send_timeout 1h; + grpc_set_header X-Real-IP $remote_addr; + } + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} +#备注: +#1、本示例使用REALITY Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)、套CDN(zh.xx.yy)来避免被封。 +#2、本示例使用不同域名来实现介绍中各应用,其办法如下: +#1)、VLESS+Vision+REALITY仅使用zv.xx.yy域名。 +#2)、VLESS+H2C+REALITY仅使用zv.xx.yy域名。 +#3)、Trojan+TCP+TLS仅使用zt.xx.yy域名。 +#4)、VMess+WebSocket+TLS仅使用zh.xx.yy域名。 +#5)、Shadowsocks+gRPC+TLS可使用zt.xx.yy域名或zh.xx.yy域名,推荐使用zt.xx.yy域名。 diff --git a/Xray(M+K+F+B+G+A)+Nginx/2_xray_config.json b/Xray(M+K+F+B+G+A)+Nginx/2_xray_config.json new file mode 100644 index 00000000000..d8d002ae8bc --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Nginx/2_xray_config.json @@ -0,0 +1,235 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "listen": "/dev/shm/vless.sock", //VLESS+Vision+REALITY监听进程 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "5443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": "@vlessh2c", //回落给VLESS+H2C监听进程 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给如下VLESS+H2C应用。1或2表示PROXY protocol版本。多级传递,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "reality", + "realitySettings": { + "show": false, //选填,若为true输出调试信息。 + "dest": "/dev/shm/https.sock", //转发给自己的网站监听进程 + "xver": 2, //开启PROXY protocol发送,发送真实来源IP和端口给自己的网站。1或2表示PROXY protocol版本。 + "serverNames": [ //必填,客户端可用的serverName列表,暂不支持*通配符。 + "zv.xx.yy" //修改为自己的网站域名 + ], + "privateKey": "qZbyc2jAkWAhFEI7P5qhfBpI5yt4pgTS8-HgjpPjt8U", //修改为自己执行./xray x25519后生成的一对密钥中私钥。 + "shortIds": [ //必填,客户端可用的shortId列表,可用于区分不同的客户端。 + "" //若有此项,客户端shortId可为空。若不为空,可0到f(0123456789abcdef),长度为2的倍数,长度上限为16。 + ] + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Nginx SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "@vlessh2c", //VLESS+H2C监听进程 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2005@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "none", + "sockopt": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收VLESS+Vision+REALITY回落前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "/dev/shm/trojan.sock", //Trojan+TCP+TLS监听进程 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy6443", //修改为自己密码 + "email": "6443@gmail.com" + } + ], + "fallbacks": [ + { + "alpn": "h2", //h2回落匹配 + "dest": "/dev/shm/h2c.sock", //h2回落进程 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。与上一致,建议配置2。 + }, + { + "dest": "/dev/shm/h1.sock", //http/1.1回落进程 + "xver": 2 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。与上一致,建议配置2。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/wildcard_.xx.yy/wildcard_.xx.yy.crt", //换成自己的通配符证书或SAN证书,绝对路径。 + "keyFile": "/home/tls/wildcard_.xx.yy/wildcard_.xx.yy.key" //换成自己的通配符密钥或SAN密钥,绝对路径。 + } + ], + "minVersion": "1.2", + "maxVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256" //非AES算法的密码套件。若无RSA证书,可删除RSA算法的密码套件;无ECC证书,可删除ECDSA算法的密码套件。 + }, + "tcpSettings": { + "acceptProxyProtocol": true //开启PROXY protocol接收,接收Nginx SNI分流前真实来源IP和端口。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "/dev/shm/vmessws.sock", //VMess+WebSocket监听进程 + "protocol": "vmess", + "settings": { + "clients": [ + { + "id": "21376258-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2001@gmail.com" + } + ] + }, + "streamSettings": { + "network": "ws", + "security": "none", + "wsSettings": { + "path": "/HALdGZ9k" //修改为自己的path + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "listen": "127.0.0.1", //只监听本机,避免本机外的机器探测到下面端口。 + "port": 2011, //Shadowsocks+gRPC监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "none", + "grpcSettings": { + "serviceName": "SALdGZ9k" //修改为自己的gRPC服务名称,类似于HTTP/2中的Path。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + }, + { + "port": 2052, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "0a652466-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "2052@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "kcp", + "security": "none", + "kcpSettings": { + "uplinkCapacity": 100, + "downlinkCapacity": 100, + "congestion": true, //启用拥塞控制 + "seed": "60VoqhfjP79nBQyU" //修改为自己的seed密码 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} +//备注: +//1、本配置支持REALITY Vision配置(zv.xx.yy)、非AES算法的密码套件配置(zt.xx.yy)。 diff --git a/Xray(M+K+F+B+G+A)+Nginx/README.md b/Xray(M+K+F+B+G+A)+Nginx/README.md new file mode 100644 index 00000000000..e6792785fa7 --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Nginx/README.md @@ -0,0 +1,35 @@ +介绍: + +利用 Nginx 支持 SNI 分流特性,对 VLESS+Vision+REALITY、Trojan+TCP+TLS、HTTPS server 进行 SNI 分流(四层转发),实现除 Xray 的 mKCP 应用外共用 443 端口。其中 VLESS+Vision+REALITY 回落(套娃) VLESS+H2C;Nginx 同时为 Trojan+TCP+TLS 提供回落服务(WEB 服务),为 Xray 的 WebSocket 与 gRPC 提供反向代理,其应用如下: + +1、M=VLESS+Vision+REALITY(回落与转发配置,REALITY 由自己启用及处理。) + +2、K=VLESS+H2C+REALITY(REALITY 由 VLESS+Vision+REALITY 启用及处理,不需配置。) + +3、F=Trojan+TCP+TLS(回落/分流配置,TLS 由自己启用及处理。) + +4、B=VMess+WebSocket+TLS(TLS 由 Nginx 启用及处理,不需配置。) + +5、G=Shadowsocks+gRPC+TLS(TLS 由 Nginx 启用及处理,不需配置。) + +6、A=VLESS+mKCP+seed + +注意: + +1、Nginx 支持 SNI 分流需要 Nginx 包含 stream_core_module 和 stream_ssl_preread_module 模块。 + +2、Xray 版本不小于 v1.8.0 才支持 REALITY,其同步 uTLS(强制客户端必须使用指纹伪造)。 + +3、Xray 的监听地址不支持 Shadowsocks 协议使用 UDS 监听。 + +4、Nginx 支持 H2C server、HTTP/2 server 及 gRPC proxy 需要 Nginx 包含 http_ssl_module 与 http_v2_module 模块及 OpenSSL 库。 + +5、Nginx 支持 H2C server,但不支持 HTTP/1.1 server 与 H2C server 共用一个端口或一个进程;故回落分成 http/1.1 回落与 h2 回落分别对应 Nginx 的 HTTP/1.1 server 与 H2C server。 + +6、Nginx 支持请求标头还原为真实客户端地址需要 Nginx 包含 http_realip_module 模块。 + +7、不要使用 ACME 客户端在采用本示例的服务器上以 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书,因 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书需监听 80 或 443 端口,从而与当前应用端口冲突。 + +8、配置1:使用 Local Loopback 连接,且启用了 PROXY protocol。配置2:使用 UDS 连接(对应 Shadowsocks+gRPC+TLS 除外),且启用了 PROXY protocol。 + +9、本示例 F 兼容原版 Trojan 的服务端应用,即可使用 Trojan 或 Trojan-Go 客户端连接。 diff --git a/Xray(M+K+F+B+G+A)+Nginx/xray_SS-2022_config.json b/Xray(M+K+F+B+G+A)+Nginx/xray_SS-2022_config.json new file mode 100644 index 00000000000..87803a31d96 --- /dev/null +++ b/Xray(M+K+F+B+G+A)+Nginx/xray_SS-2022_config.json @@ -0,0 +1,46 @@ +//Shadowsocks-2022配置 +//原配置: +//........<省略>........ + "settings": { + "method": "chacha20-poly1305", + "password": "diy2011", //修改为自己的密码 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//以上配置修改为如下: +//单用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-chacha20-poly1305", //Shadowsocks-2022加密方法之一 + "password": "81qjRtwJZWx2gBphrLk18WZQ06B3Y2Vxlnqe903xXqU=", //修改为自己的密钥 + "email": "2011@gmail.com" + }, +//........<省略>........ + +//多用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-aes-128-gcm", //Shadowsocks-2022加密方法之一 + "password": "rvQ6fK6Y4ckgFVslZlZUgQ==", //修改为自己的主项密钥 + "clients": [ + { + "password": "FPTg9fyNve167Fg8oPkFlQ==", //修改为自己的分项密钥 + "email": "2011@gmail.com" + }, + { + "password": "dkv04xu1f+UeM3mXpNJgVA==", //修改为自己的分项密钥 + "email": "2021@gmail.com" + } + ] + }, +//........<省略>........ +//备注: +//1、Xray从v1.5.9版开始支持Shadowsocks-2022。 +//2、密钥生成及长度 +//在服务器上直接使用‘openssl rand -base64 <长度> ’命令生成符合如下加密方法的对应密钥。 +// 加密方法 密钥长度 +//2022-blake3-aes-128-gcm 16 +//2022-blake3-aes-256-gcm 32 +//2022-blake3-chacha20-poly1305 32 +//3、多用户的客户端的密钥为主项密钥:分项密钥的组合,如rvQ6fK6Y4ckgFVslZlZUgQ==:FPTg9fyNve167Fg8oPkFlQ==。 diff --git a/Xray(SS+gRPC+REALITY)/README.md b/Xray(SS+gRPC+REALITY)/README.md new file mode 100644 index 00000000000..0bb68ff4dc6 --- /dev/null +++ b/Xray(SS+gRPC+REALITY)/README.md @@ -0,0 +1,15 @@ +介绍: + +本示例实现类似 V2Ray 或 Xray 的 [Shadowsocks+gRPC+TLS](https://github.com/lxhao61/integrated-examples/tree/main/V2Ray(SS%2BgRPC)%2BCaddy%5CNginx) 应用,TLS 由 REALITY 取代。可消除服务端 TLS 指纹特征,仍有前向保密性等,且证书链攻击无效,安全性超越常规 TLS。可指向别人的网站,无需自己买域名、配置 TLS 服务端,更方便,实现向中间人呈现指定 SNI 的全程真实 TLS,可解决 SNI 名单阻断问题。 + +原理: + +使用目标网站证书(受信证书)的 TLS 伪装代理。 + +注意: + +1、Xray 版本不小于 v1.8.0 才支持 REALITY,其同步 uTLS(强制客户端必须使用指纹伪造)。 + +2、若目标网站使用外部的,其网站最低要求:国外网站、域名非跳转、支持 TLSv1.3 与 HTTP/2,是否符合要求可用 [SSL Server Test](https://www.ssllabs.com/ssltest/) 检查。 + +3、若目标网站使用自己的,其配置修改及网站配置可参考 [Xray(M+K+B+G+A)+Nginx](https://github.com/lxhao61/integrated-examples/tree/main/Xray(M%2BK%2BB%2BG%2BA)%2BNginx) 或 [Xray(M+K+B+G+A)+Caddy(N+T)](https://github.com/lxhao61/integrated-examples/tree/main/Xray(M%2BK%2BB%2BG%2BA)%2BCaddy(N%2BT)) 示例。 diff --git a/Xray(SS+gRPC+REALITY)/xray_SS-2022_config.json b/Xray(SS+gRPC+REALITY)/xray_SS-2022_config.json new file mode 100644 index 00000000000..fc4876f6110 --- /dev/null +++ b/Xray(SS+gRPC+REALITY)/xray_SS-2022_config.json @@ -0,0 +1,46 @@ +//Shadowsocks-2022配置 +//原配置: +//........<省略>........ + "settings": { + "method": "chacha20-poly1305", + "password": "diy443", //修改为自己的密码 + "email": "443@gmail.com" + }, +//........<省略>........ + +//以上配置修改为如下: +//单用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-chacha20-poly1305", //Shadowsocks-2022加密方法之一 + "password": "81qjRtwJZWx2gBphrLk18WZQ06B3Y2Vxlnqe903xXqU=", //修改为自己的密钥 + "email": "443@gmail.com" + }, +//........<省略>........ + +//多用户 +//........<省略>........ + "settings": { + "method": "2022-blake3-aes-128-gcm", //Shadowsocks-2022加密方法之一 + "password": "rvQ6fK6Y4ckgFVslZlZUgQ==", //修改为自己的主项密钥 + "clients": [ + { + "password": "FPTg9fyNve167Fg8oPkFlQ==", //修改为自己的分项密钥 + "email": "4431@gmail.com" + }, + { + "password": "dkv04xu1f+UeM3mXpNJgVA==", //修改为自己的分项密钥 + "email": "4432@gmail.com" + } + ] + }, +//........<省略>........ +//备注: +//1、Xray从v1.5.9版开始支持Shadowsocks-2022。 +//2、密钥生成及长度 +//在服务器上直接使用‘openssl rand -base64 <长度> ’命令生成符合如下加密方法的对应密钥。 +// 加密方法 密钥长度 +//2022-blake3-aes-128-gcm 16 +//2022-blake3-aes-256-gcm 32 +//2022-blake3-chacha20-poly1305 32 +//3、多用户的客户端的密钥为主项密钥:分项密钥的组合,如rvQ6fK6Y4ckgFVslZlZUgQ==:FPTg9fyNve167Fg8oPkFlQ==。 diff --git a/Xray(SS+gRPC+REALITY)/xray_config.json b/Xray(SS+gRPC+REALITY)/xray_config.json new file mode 100644 index 00000000000..359852c03f5 --- /dev/null +++ b/Xray(SS+gRPC+REALITY)/xray_config.json @@ -0,0 +1,63 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //监听端口 + "protocol": "shadowsocks", + "settings": { + "method": "chacha20-poly1305", + "password": "diy443", //修改为自己的密码 + "email": "443@gmail.com" + }, + "streamSettings": { + "network": "grpc", + "security": "reality", + "realitySettings": { + "show": false, //选填,若为true输出调试信息。 + "dest": "xx.yy:443", //转发给自己选定的目标网站。目标网站使用外部的一般为xx.yy:443,目标网站使用自己的一般直接端口或UDS。 + "xver": 0, //选填,默认关闭PROXY protocol发送。可填1或2开启PROXY protocol发送,1或2表示PROXY protocol版本。 + "serverNames": [ //必填,客户端可用的serverName列表,暂不支持*通配符。 + "xx.yy" //修改为目标网站证书对应的域名 + ], + "privateKey": "qZbyc2jAkWAhFEI7P5qhfBpI5yt4pgTS8-HgjpPjt8U", //修改为自己执行./xray x25519后生成的一对密钥中私钥。 + "shortIds": [ //必填,客户端可用的shortId列表,可用于区分不同的客户端。 + "" //若有此项,客户端shortId可为空。若不为空,可0到f(0123456789abcdef),长度为2的倍数,长度上限为16。 + ] + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/Xray(Trojan+TCP+TLS)+Caddy/1_caddy.json b/Xray(Trojan+TCP+TLS)+Caddy/1_caddy.json new file mode 100644 index 00000000000..c50d7435777 --- /dev/null +++ b/Xray(Trojan+TCP+TLS)+Caddy/1_caddy.json @@ -0,0 +1,76 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "storage": { + "module": "file_system", + "root": "/home/tls" //存放TLS证书的基本路径 + }, + "apps": { + "http": { + "servers": { + "h1": { + "listen": [":80"], + "routes": [{ + "handle": [{ + "handler": "static_response", + "headers": { + "Location": ["https://{http.request.host}{http.request.uri}"] //HTTP自动跳转HTTPS,让网站看起来更真实。 + }, + "status_code": 301 + }] + }] + }, + "h1h2c": { + "listen": ["127.0.0.1:88"], //HTTP/1.1 server及H2C server本地监听端口 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }], + "routes": [{ + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "protocols": ["h1","h2c"] //开启HTTP/1.1 server与H2C server支持 + } + } + }, + "tls": { + "certificates": { + "automate": ["xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } + } +} +//备注: +//1、从Let's Encrypt申请的普通TLS证书在‘/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/xx.yy’目录中。/home/tls为存放TLS证书的基本路径,xx.yy为域名,目录根据域名变化。 +//2、从ZeroSSL申请的普通TLS证书在‘/home/tls/certificates/acme.zerossl.com-v2-dv90/xx.yy’目录中。/home/tls为存放TLS证书的基本路径,xx.yy为域名,目录根据域名变化。 +//3、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 diff --git a/Xray(Trojan+TCP+TLS)+Caddy/1_xray_config.json b/Xray(Trojan+TCP+TLS)+Caddy/1_xray_config.json new file mode 100644 index 00000000000..cf27572ad37 --- /dev/null +++ b/Xray(Trojan+TCP+TLS)+Caddy/1_xray_config.json @@ -0,0 +1,73 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //监听端口 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy443", //修改为自己密码 + "email": "443@gmail.com" + } + ], + "fallbacks": [ + { + "dest": 88, //h2与http/1.1回落端口(共用端口) + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/xx.yy/xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/xx.yy/xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "rejectUnknownSni": true, //若接收到的SNI与证书域名不匹配就拒绝TLS握手(禁止以IP方式访问网站) + "minVersion": "1.2", + "maxVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" //非AES算法的密码套件 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/Xray(Trojan+TCP+TLS)+Caddy/2_caddy.json b/Xray(Trojan+TCP+TLS)+Caddy/2_caddy.json new file mode 100644 index 00000000000..b0a9ee4aa5c --- /dev/null +++ b/Xray(Trojan+TCP+TLS)+Caddy/2_caddy.json @@ -0,0 +1,76 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "storage": { + "module": "file_system", + "root": "/home/tls" //存放TLS证书的基本路径 + }, + "apps": { + "http": { + "servers": { + "h1": { + "listen": [":80"], + "routes": [{ + "handle": [{ + "handler": "static_response", + "headers": { + "Location": ["https://{http.request.host}{http.request.uri}"] //HTTP自动跳转HTTPS,让网站看起来更真实。 + }, + "status_code": 301 + }] + }] + }, + "h1h2c": { + "listen": ["unix/@h1h2c"], //HTTP/1.1 server及H2C server监听进程 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }], + "routes": [{ + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "protocols": ["h1","h2c"] //开启HTTP/1.1 server与H2C server支持 + } + } + }, + "tls": { + "certificates": { + "automate": ["xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } + } +} +//备注: +//1、从Let's Encrypt申请的普通TLS证书在‘/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/xx.yy’目录中。/home/tls为存放TLS证书的基本路径,xx.yy为域名,目录根据域名变化。 +//2、从ZeroSSL申请的普通TLS证书在‘/home/tls/certificates/acme.zerossl.com-v2-dv90/xx.yy’目录中。/home/tls为存放TLS证书的基本路径,xx.yy为域名,目录根据域名变化。 +//3、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 diff --git a/Xray(Trojan+TCP+TLS)+Caddy/2_xray_config.json b/Xray(Trojan+TCP+TLS)+Caddy/2_xray_config.json new file mode 100644 index 00000000000..4ecb5a68381 --- /dev/null +++ b/Xray(Trojan+TCP+TLS)+Caddy/2_xray_config.json @@ -0,0 +1,73 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //监听端口 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy443", //修改为自己密码 + "email": "443@gmail.com" + } + ], + "fallbacks": [ + { + "dest": "@h1h2c", //h2与http/1.1回落进程(共用进程) + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/xx.yy/xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/xx.yy/xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "rejectUnknownSni": true, //若接收到的SNI与证书域名不匹配就拒绝TLS握手(禁止以IP方式访问网站) + "minVersion": "1.2", + "maxVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256" //非AES算法的密码套件 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/Xray(Trojan+TCP+TLS)+Caddy/README.md b/Xray(Trojan+TCP+TLS)+Caddy/README.md new file mode 100644 index 00000000000..10c3a2fb1a7 --- /dev/null +++ b/Xray(Trojan+TCP+TLS)+Caddy/README.md @@ -0,0 +1,18 @@ +介绍: + +本示例配置为 Trojan+TCP+TLS 应用。Xray 服务端前置(监听 443 端口)处理来自墙内的 HTTPS 请求,如果是合法的 Xray 客户端请求,那么为该请求提供服务(科学上网);否则将已解除 TLS 的流量请求回落(转发)给 Caddy,由 Caddy 为其提供 WEB 服务。 + +原理: + +默认流程:Xray client <-------- TCP+TLS(HTTP/2或HTTPS) -------> Xray server +回落流程:WEB client <--------------- HTTP/2或HTTPS ---------------> Xray server <-- H2C或HTTP/1.1 --> Caddy(WEB server) + +注意: + +1、Caddy 支持 HTTP/1.1 server 与 H2C server 共用一个端口或一个进程。 + +2、本示例所需 TLS 证书由 Caddy(内置 ACME 客户端) 提供,实现 TLS 证书自动申请及更新。 + +3、配置1:使用 Local Loopback 连接,且启用了 PROXY protocol。配置2:使用 UDS 连接,且启用了 PROXY protocol。 + +4、本示例兼容原版 Trojan 的服务端应用,即可使用 Trojan 或 Trojan-Go 客户端连接。 diff --git a/Xray(Trojan+TCP+TLS)+Nginx/1_nginx.conf b/Xray(Trojan+TCP+TLS)+Nginx/1_nginx.conf new file mode 100644 index 00000000000..e021b480940 --- /dev/null +++ b/Xray(Trojan+TCP+TLS)+Nginx/1_nginx.conf @@ -0,0 +1,45 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 127.0.0.1:81 proxy_protocol; #HTTP/1.1 server本地监听端口与开启PROXY protocol接收 + listen 127.0.0.1:82 http2 proxy_protocol; #H2C server本地监听端口与开启PROXY protocol接收 + set_real_ip_from 127.0.0.1; + real_ip_header proxy_protocol; + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} diff --git a/Xray(Trojan+TCP+TLS)+Nginx/1_xray_config.json b/Xray(Trojan+TCP+TLS)+Nginx/1_xray_config.json new file mode 100644 index 00000000000..6b4b227c01e --- /dev/null +++ b/Xray(Trojan+TCP+TLS)+Nginx/1_xray_config.json @@ -0,0 +1,78 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //监听端口 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy443", //修改为自己密码 + "email": "443@gmail.com" + } + ], + "fallbacks": [ + { + "alpn": "h2", //h2回落匹配 + "dest": 82, //h2回落端口 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + }, + { + "dest": 81, //http/1.1回落端口 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/xx.yy/xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/xx.yy/xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "rejectUnknownSni": true, //若接收到的SNI与证书域名不匹配就拒绝TLS握手(禁止以IP方式访问网站) + "minVersion": "1.2", + "maxVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256" //非AES算法的密码套件。若无RSA证书,可删除RSA算法的密码套件;无ECC证书,可删除ECDSA算法的密码套件。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/Xray(Trojan+TCP+TLS)+Nginx/2_nginx.conf b/Xray(Trojan+TCP+TLS)+Nginx/2_nginx.conf new file mode 100644 index 00000000000..672dd9f2e05 --- /dev/null +++ b/Xray(Trojan+TCP+TLS)+Nginx/2_nginx.conf @@ -0,0 +1,45 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen unix:/dev/shm/h1.sock proxy_protocol; #HTTP/1.1 server监听进程与开启PROXY protocol接收 + listen unix:/dev/shm/h2c.sock http2 proxy_protocol; #H2C server监听进程与开启PROXY protocol接收 + set_real_ip_from unix:; + real_ip_header proxy_protocol; + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} diff --git a/Xray(Trojan+TCP+TLS)+Nginx/2_xray_config.json b/Xray(Trojan+TCP+TLS)+Nginx/2_xray_config.json new file mode 100644 index 00000000000..ee3c0545c2d --- /dev/null +++ b/Xray(Trojan+TCP+TLS)+Nginx/2_xray_config.json @@ -0,0 +1,78 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //监听端口 + "protocol": "trojan", + "settings": { + "clients": [ + { + "password":"diy443", //修改为自己密码 + "email": "443@gmail.com" + } + ], + "fallbacks": [ + { + "alpn": "h2", //h2回落匹配 + "dest": "/dev/shm/h2c.sock", //h2回落进程 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + }, + { + "dest": "/dev/shm/h1.sock", //http/1.1回落进程 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/xx.yy/xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/xx.yy/xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "rejectUnknownSni": true, //若接收到的SNI与证书域名不匹配就拒绝TLS握手(禁止以IP方式访问网站) + "minVersion": "1.2", + "maxVersion": "1.2", + "cipherSuites": "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256:TLS_ECDHE_RSA_WITH_CHACHA20_POLY1305_SHA256" //非AES算法的密码套件。若无RSA证书,可删除RSA算法的密码套件;无ECC证书,可删除ECDSA算法的密码套件。 + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/Xray(Trojan+TCP+TLS)+Nginx/README.md b/Xray(Trojan+TCP+TLS)+Nginx/README.md new file mode 100644 index 00000000000..c6d2241b033 --- /dev/null +++ b/Xray(Trojan+TCP+TLS)+Nginx/README.md @@ -0,0 +1,22 @@ +介绍: + +本示例配置为 Trojan+TCP+TLS 应用。Xray 服务端前置(监听 443 端口)处理来自墙内的 HTTPS 请求,如果是合法的 Xray 客户端请求,那么为该请求提供服务(科学上网);否则将已解除 TLS 的流量请求回落(转发)给 Nginx,由 Nginx 为其提供 WEB 服务。 + +原理: + +默认流程:Xray client <-------- TCP+TLS(HTTP/2或HTTPS) -------> Xray server +回落流程:WEB client <--------------- HTTP/2或HTTPS ---------------> Xray server <-- H2C或HTTP/1.1 --> Nginx(WEB server) + +注意: + +1、Nginx 支持 H2C server 需要 Nginx 包含 http_v2_module 模块。 + +2、Nginx 支持 H2C server,但不支持 HTTP/1.1 server 与 H2C server 共用一个端口或一个进程;故回落分成 http/1.1 回落与 h2 回落分别对应 Nginx 的 HTTP/1.1 server 与 H2C server。 + +3、Nginx 支持请求标头还原为真实客户端地址需要 Nginx 包含 http_realip_module 模块。 + +4、不要使用 ACME 客户端在采用本示例的服务器上以 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书,因 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书需监听 80 或 443 端口,从而与当前应用端口冲突。 + +5、配置1:使用 Local Loopback 连接,且启用了 PROXY protocol。配置2:使用 UDS 连接,且启用了 PROXY protocol。 + +6、本示例兼容原版 Trojan 的服务端应用,即可使用 Trojan 或 Trojan-Go 客户端连接。 diff --git a/Xray(VLESS+H2C+REALITY)/README.md b/Xray(VLESS+H2C+REALITY)/README.md new file mode 100644 index 00000000000..84e2139ce3f --- /dev/null +++ b/Xray(VLESS+H2C+REALITY)/README.md @@ -0,0 +1,15 @@ +介绍: + +本示例实现类似 V2Ray 或 Xray 的 [VLESS+H2C+TLS](https://github.com/lxhao61/integrated-examples/tree/main/V2Ray(VLESS%2BH2C)%2BCaddy) 应用,TLS 由 REALITY 取代。可消除服务端 TLS 指纹特征,仍有前向保密性等,且证书链攻击无效,安全性超越常规 TLS。可指向别人的网站,无需自己买域名、配置 TLS 服务端,更方便,实现向中间人呈现指定 SNI 的全程真实 TLS,可解决 SNI 名单阻断问题。 + +原理: + +使用目标网站证书(受信证书)的 TLS 伪装代理。 + +注意: + +1、Xray 版本不小于 v1.8.0 才支持 REALITY,其同步 uTLS(强制客户端必须使用指纹伪造)。 + +2、若目标网站使用外部的,其网站最低要求:国外网站、域名非跳转、支持 TLSv1.3 与 HTTP/2,是否符合要求可用 [SSL Server Test](https://www.ssllabs.com/ssltest/) 检查。 + +3、若目标网站使用自己的,其配置修改及网站配置可参考 [Xray(M+K+B+G+A)+Nginx](https://github.com/lxhao61/integrated-examples/tree/main/Xray(M%2BK%2BB%2BG%2BA)%2BNginx) 或 [Xray(M+K+B+G+A)+Caddy(N+T)](https://github.com/lxhao61/integrated-examples/tree/main/Xray(M%2BK%2BB%2BG%2BA)%2BCaddy(N%2BT)) 示例。 diff --git a/Xray(VLESS+H2C+REALITY)/xray_config.json b/Xray(VLESS+H2C+REALITY)/xray_config.json new file mode 100644 index 00000000000..4fd162a24d8 --- /dev/null +++ b/Xray(VLESS+H2C+REALITY)/xray_config.json @@ -0,0 +1,67 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "email": "443@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "h2", + "security": "reality", + "realitySettings": { + "show": false, //选填,若为true输出调试信息。 + "dest": "xx.yy:443", //转发给自己选定的目标网站。目标网站使用外部的一般为xx.yy:443,目标网站使用自己的一般直接端口或UDS。 + "xver": 0, //选填,默认关闭PROXY protocol发送。可填1或2开启PROXY protocol发送,1或2表示PROXY protocol版本。 + "serverNames": [ //必填,客户端可用的serverName列表,暂不支持*通配符。 + "xx.yy" //修改为目标网站证书对应的域名 + ], + "privateKey": "qZbyc2jAkWAhFEI7P5qhfBpI5yt4pgTS8-HgjpPjt8U", //修改为自己执行./xray x25519后生成的一对密钥中私钥。 + "shortIds": [ //必填,客户端可用的shortId列表,可用于区分不同的客户端。 + "" //若有此项,客户端shortId可为空。若不为空,可0到f(0123456789abcdef),长度为2的倍数,长度上限为16。 + ] + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/Xray(VLESS+Vision+REALITY)/README.md b/Xray(VLESS+Vision+REALITY)/README.md new file mode 100644 index 00000000000..a4c5997747d --- /dev/null +++ b/Xray(VLESS+Vision+REALITY)/README.md @@ -0,0 +1,15 @@ +介绍: + +本示例实现类似 Xray 的 VLESS+Vision+TLS(对应 [Xray(VLESS+Vision+TLS)+Nginx](https://github.com/lxhao61/integrated-examples/tree/main/Xray(VLESS+Vision+TLS)+Nginx) 或 [Xray(VLESS+Vision+TLS)+Caddy](https://github.com/lxhao61/integrated-examples/tree/main/Xray(VLESS%2BVision%2BTLS)%2BCaddy) 示例) 应用,TLS 由 REALITY 取代。可消除服务端 TLS 指纹特征,仍有前向保密性等,且证书链攻击无效,安全性超越常规 TLS。可指向别人的网站,无需自己买域名、配置 TLS 服务端,更方便,实现向中间人呈现指定 SNI 的全程真实 TLS,可解决 SNI 名单阻断问题。 + +原理: + +使用目标网站证书(受信证书)的 TLS 伪装代理。 + +注意: + +1、Xray 版本不小于 v1.8.0 才支持 REALITY,其同步 uTLS(强制客户端必须使用指纹伪造)。 + +2、若目标网站使用外部的,其网站最低要求:国外网站、域名非跳转、支持 TLSv1.3 与 HTTP/2,是否符合要求可用 [SSL Server Test](https://www.ssllabs.com/ssltest/) 检查。 + +3、若目标网站使用自己的,其配置修改及网站配置可参考 [Xray(M+K+B+G+A)+Nginx](https://github.com/lxhao61/integrated-examples/tree/main/Xray(M%2BK%2BB%2BG%2BA)%2BNginx) 或 [Xray(M+K+B+G+A)+Caddy(N+T)](https://github.com/lxhao61/integrated-examples/tree/main/Xray(M%2BK%2BB%2BG%2BA)%2BCaddy(N%2BT)) 示例。 diff --git a/Xray(VLESS+Vision+REALITY)/xray_config.json b/Xray(VLESS+Vision+REALITY)/xray_config.json new file mode 100644 index 00000000000..88a55bb75d9 --- /dev/null +++ b/Xray(VLESS+Vision+REALITY)/xray_config.json @@ -0,0 +1,68 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "443@gmail.com" + } + ], + "decryption": "none" + }, + "streamSettings": { + "network": "tcp", + "security": "reality", + "realitySettings": { + "show": false, //选填,若为true输出调试信息。 + "dest": "xx.yy:443", //转发给自己选定的目标网站。目标网站使用外部的一般为xx.yy:443,目标网站使用自己的一般直接端口或UDS。 + "xver": 0, //选填,默认关闭PROXY protocol发送。可填1或2开启PROXY protocol发送,1或2表示PROXY protocol版本。 + "serverNames": [ //必填,客户端可用的serverName列表,暂不支持*通配符。 + "xx.yy" //修改为目标网站证书对应的域名 + ], + "privateKey": "qZbyc2jAkWAhFEI7P5qhfBpI5yt4pgTS8-HgjpPjt8U", //修改为自己执行./xray x25519后生成的一对密钥中私钥。 + "shortIds": [ //必填,客户端可用的shortId列表,可用于区分不同的客户端。 + "" //若有此项,客户端shortId可为空。若不为空,可0到f(0123456789abcdef),长度为2的倍数,长度上限为16。 + ] + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/Xray(VLESS+Vision+TLS)+Caddy/1_caddy.json b/Xray(VLESS+Vision+TLS)+Caddy/1_caddy.json new file mode 100644 index 00000000000..c50d7435777 --- /dev/null +++ b/Xray(VLESS+Vision+TLS)+Caddy/1_caddy.json @@ -0,0 +1,76 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "storage": { + "module": "file_system", + "root": "/home/tls" //存放TLS证书的基本路径 + }, + "apps": { + "http": { + "servers": { + "h1": { + "listen": [":80"], + "routes": [{ + "handle": [{ + "handler": "static_response", + "headers": { + "Location": ["https://{http.request.host}{http.request.uri}"] //HTTP自动跳转HTTPS,让网站看起来更真实。 + }, + "status_code": 301 + }] + }] + }, + "h1h2c": { + "listen": ["127.0.0.1:88"], //HTTP/1.1 server及H2C server本地监听端口 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }], + "routes": [{ + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "protocols": ["h1","h2c"] //开启HTTP/1.1 server与H2C server支持 + } + } + }, + "tls": { + "certificates": { + "automate": ["xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } + } +} +//备注: +//1、从Let's Encrypt申请的普通TLS证书在‘/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/xx.yy’目录中。/home/tls为存放TLS证书的基本路径,xx.yy为域名,目录根据域名变化。 +//2、从ZeroSSL申请的普通TLS证书在‘/home/tls/certificates/acme.zerossl.com-v2-dv90/xx.yy’目录中。/home/tls为存放TLS证书的基本路径,xx.yy为域名,目录根据域名变化。 +//3、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 diff --git a/Xray(VLESS+Vision+TLS)+Caddy/1_xray_config.json b/Xray(VLESS+Vision+TLS)+Caddy/1_xray_config.json new file mode 100644 index 00000000000..37ed88eb8bd --- /dev/null +++ b/Xray(VLESS+Vision+TLS)+Caddy/1_xray_config.json @@ -0,0 +1,73 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": 88, //h2与http/1.1回落端口(共用端口) + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/xx.yy/xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/xx.yy/xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "rejectUnknownSni": true, //若接收到的SNI与证书域名不匹配就拒绝TLS握手(禁止以IP方式访问网站) + "minVersion": "1.2" + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/Xray(VLESS+Vision+TLS)+Caddy/2_caddy.json b/Xray(VLESS+Vision+TLS)+Caddy/2_caddy.json new file mode 100644 index 00000000000..b0a9ee4aa5c --- /dev/null +++ b/Xray(VLESS+Vision+TLS)+Caddy/2_caddy.json @@ -0,0 +1,76 @@ +{ + "admin": { + "disabled": true + }, + "logging": { + "logs": { + "default": { + "writer": { + "output": "file", + "filename": "/var/log/caddy/error.log" + }, + "level": "ERROR" + } + } + }, + "storage": { + "module": "file_system", + "root": "/home/tls" //存放TLS证书的基本路径 + }, + "apps": { + "http": { + "servers": { + "h1": { + "listen": [":80"], + "routes": [{ + "handle": [{ + "handler": "static_response", + "headers": { + "Location": ["https://{http.request.host}{http.request.uri}"] //HTTP自动跳转HTTPS,让网站看起来更真实。 + }, + "status_code": 301 + }] + }] + }, + "h1h2c": { + "listen": ["unix/@h1h2c"], //HTTP/1.1 server及H2C server监听进程 + "listener_wrappers": [{ + "wrapper": "proxy_protocol" //开启PROXY protocol接收 + }], + "routes": [{ + "handle": [{ + "handler": "headers", + "response": { + "set": { + "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"] //启用HSTS + } + } + }, + { + "handler": "file_server", + "root": "/var/www/html" //修改为自己存放的WEB文件路径 + }] + }], + "protocols": ["h1","h2c"] //开启HTTP/1.1 server与H2C server支持 + } + } + }, + "tls": { + "certificates": { + "automate": ["xx.yy"] //自动化管理TLS证书(包括获取、更新及加载证书)。修改为自己的域名。 + }, + "automation": { + "policies": [{ + "issuers": [{ + "module": "acme", //acme表示从Let's Encrypt申请TLS证书,zerossl表示从ZeroSSL申请TLS证书。必须acme与zerossl二选一(固定TLS证书的目录便于引用)。 + "email": "your@email.com" //修改为自己的电子邮箱(选配) + }] + }] + } + } + } +} +//备注: +//1、从Let's Encrypt申请的普通TLS证书在‘/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/xx.yy’目录中。/home/tls为存放TLS证书的基本路径,xx.yy为域名,目录根据域名变化。 +//2、从ZeroSSL申请的普通TLS证书在‘/home/tls/certificates/acme.zerossl.com-v2-dv90/xx.yy’目录中。/home/tls为存放TLS证书的基本路径,xx.yy为域名,目录根据域名变化。 +//3、本配置仅支持申请普通TLS证书,若要申请通配符TLS证书请参考‘Caddy(Other Configuration) (Caddy的特殊应用配置方法。)’中对应介绍及对应配置示例。 diff --git a/Xray(VLESS+Vision+TLS)+Caddy/2_xray_config.json b/Xray(VLESS+Vision+TLS)+Caddy/2_xray_config.json new file mode 100644 index 00000000000..cf9168492bc --- /dev/null +++ b/Xray(VLESS+Vision+TLS)+Caddy/2_xray_config.json @@ -0,0 +1,73 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "dest": "@h1h2c", //h2与http/1.1回落进程(共用进程) + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Caddy。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/xx.yy/xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/certificates/acme-v02.api.letsencrypt.org-directory/xx.yy/xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "rejectUnknownSni": true, //若接收到的SNI与证书域名不匹配就拒绝TLS握手(禁止以IP方式访问网站) + "minVersion": "1.2" + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/Xray(VLESS+Vision+TLS)+Caddy/README.md b/Xray(VLESS+Vision+TLS)+Caddy/README.md new file mode 100644 index 00000000000..59cba39249f --- /dev/null +++ b/Xray(VLESS+Vision+TLS)+Caddy/README.md @@ -0,0 +1,18 @@ +介绍: + +本示例配置为 VLESS+Vision+TLS 应用。Xray 服务端前置(监听 443 端口)处理来自墙内的 HTTPS 请求,如果是合法的 Xray 客户端请求,那么为该请求提供服务(科学上网);否则将已解除 TLS 的流量请求回落(转发)给 Caddy,由 Caddy 为其提供 WEB 服务。 + +原理: + +默认流程:Xray client <-------- TCP+TLS(HTTP/2或HTTPS) -------> Xray server +回落流程:WEB client <--------------- HTTP/2或HTTPS ---------------> Xray server <-- H2C或HTTP/1.1 --> Caddy(WEB server) + +注意: + +1、Xray 版本不小于 v1.7.2 才完美支持 VLESS 协议的 XTLS Vision 应用。 + +2、Caddy 支持 HTTP/1.1 server 与 H2C server 共用一个端口或一个进程。 + +3、本示例所需 TLS 证书由 Caddy(内置 ACME 客户端) 提供,实现 TLS 证书自动申请及更新。 + +4、配置1:使用 Local Loopback 连接,且启用了 PROXY protocol。配置2:使用 UDS 连接,且启用了 PROXY protocol。 diff --git a/Xray(VLESS+Vision+TLS)+Nginx/1_nginx.conf b/Xray(VLESS+Vision+TLS)+Nginx/1_nginx.conf new file mode 100644 index 00000000000..e021b480940 --- /dev/null +++ b/Xray(VLESS+Vision+TLS)+Nginx/1_nginx.conf @@ -0,0 +1,45 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen 127.0.0.1:81 proxy_protocol; #HTTP/1.1 server本地监听端口与开启PROXY protocol接收 + listen 127.0.0.1:82 http2 proxy_protocol; #H2C server本地监听端口与开启PROXY protocol接收 + set_real_ip_from 127.0.0.1; + real_ip_header proxy_protocol; + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} diff --git a/Xray(VLESS+Vision+TLS)+Nginx/1_xray_config.json b/Xray(VLESS+Vision+TLS)+Nginx/1_xray_config.json new file mode 100644 index 00000000000..b700aa5ac15 --- /dev/null +++ b/Xray(VLESS+Vision+TLS)+Nginx/1_xray_config.json @@ -0,0 +1,78 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "alpn": "h2", //h2回落匹配 + "dest": 82, //h2回落端口 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + }, + { + "dest": 81, //http/1.1回落端口 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/xx.yy/xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/xx.yy/xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "rejectUnknownSni": true, //若接收到的SNI与证书域名不匹配就拒绝TLS握手(禁止以IP方式访问网站) + "minVersion": "1.2" + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/Xray(VLESS+Vision+TLS)+Nginx/2_nginx.conf b/Xray(VLESS+Vision+TLS)+Nginx/2_nginx.conf new file mode 100644 index 00000000000..672dd9f2e05 --- /dev/null +++ b/Xray(VLESS+Vision+TLS)+Nginx/2_nginx.conf @@ -0,0 +1,45 @@ + +#user nobody nogroup; #表示以默认用户(root)运行。若取消注释,注意修改为相应权限的用户与组。 +worker_processes auto; + +error_log /var/log/nginx/error.log; #错误日志的文件地址 + +pid /run/nginx.pid; + +events { + worker_connections 1024; +} + +http { + include mime.types; + default_type application/octet-stream; + + log_format main '$remote_addr - $remote_user [$time_local] "$request" ' + '$status $body_bytes_sent "$http_referer" ' + '"$http_user_agent" "$http_x_forwarded_for"'; + + access_log /var/log/nginx/access.log main; #访问日志的文件地址 + + sendfile on; + + keepalive_timeout 65; + + server { + listen 80; + listen [::]:80; #无IPv6,此项可以删除。 + return 301 https://$host$request_uri; #HTTP自动跳转HTTPS,让网站看起来更真实。 + } + + server { + listen unix:/dev/shm/h1.sock proxy_protocol; #HTTP/1.1 server监听进程与开启PROXY protocol接收 + listen unix:/dev/shm/h2c.sock http2 proxy_protocol; #H2C server监听进程与开启PROXY protocol接收 + set_real_ip_from unix:; + real_ip_header proxy_protocol; + + location / { + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains; preload" always; #启用HSTS + root /var/www/html; #修改为自己存放的WEB文件路径 + index index.html index.htm; + } + } +} diff --git a/Xray(VLESS+Vision+TLS)+Nginx/2_xray_config.json b/Xray(VLESS+Vision+TLS)+Nginx/2_xray_config.json new file mode 100644 index 00000000000..17e24410d0b --- /dev/null +++ b/Xray(VLESS+Vision+TLS)+Nginx/2_xray_config.json @@ -0,0 +1,78 @@ +{ + "log": { + "loglevel": "warning", + "error": "/var/log/xray/error.log", + "access": "/var/log/xray/access.log" + }, + "inbounds": [ + { + "port": 443, //监听端口 + "protocol": "vless", + "settings": { + "clients": [ + { + "id": "048e0bf2-dd56-11e9-aa37-5600024c1d6a", //修改为自己的UUID + "flow": "xtls-rprx-vision", //启用XTLS Vision + "email": "443@gmail.com" + } + ], + "decryption": "none", + "fallbacks": [ + { + "alpn": "h2", //h2回落匹配 + "dest": "/dev/shm/h2c.sock", //h2回落进程 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + }, + { + "dest": "/dev/shm/h1.sock", //http/1.1回落进程 + "xver": 1 //开启PROXY protocol发送,发送真实来源IP和端口给Nginx。1或2表示PROXY protocol版本。 + } + ] + }, + "streamSettings": { + "network": "tcp", + "security": "tls", + "tlsSettings": { + "certificates": [ + { + "ocspStapling": 3600, + "certificateFile": "/home/tls/xx.yy/xx.yy.crt", //换成自己的证书,绝对路径。 + "keyFile": "/home/tls/xx.yy/xx.yy.key" //换成自己的密钥,绝对路径。 + } + ], + "rejectUnknownSni": true, //若接收到的SNI与证书域名不匹配就拒绝TLS握手(禁止以IP方式访问网站) + "minVersion": "1.2" + } + }, + "sniffing": { + "enabled": true, + "destOverride": [ + "http", + "tls" + ] + } + } + ], + "routing": { + "rules": [ + { + "type": "field", + "protocol": [ + "bittorrent" + ], + "outboundTag": "blocked" + } + ] + }, + "outbounds": [ + { + "protocol": "freedom", + "settings": {} + }, + { + "tag": "blocked", + "protocol": "blackhole", + "settings": {} + } + ] +} diff --git a/Xray(VLESS+Vision+TLS)+Nginx/README.md b/Xray(VLESS+Vision+TLS)+Nginx/README.md new file mode 100644 index 00000000000..ea1f4e74fc3 --- /dev/null +++ b/Xray(VLESS+Vision+TLS)+Nginx/README.md @@ -0,0 +1,22 @@ +介绍: + +本示例配置为 VLESS+Vision+TLS 应用。Xray 服务端前置(监听 443 端口)处理来自墙内的 HTTPS 请求,如果是合法的 Xray 客户端请求,那么为该请求提供服务(科学上网);否则将已解除 TLS 的流量请求回落(转发)给 Nginx,由 Nginx 为其提供 WEB 服务。 + +原理: + +默认流程:Xray client <-------- TCP+TLS(HTTP/2或HTTPS) -------> Xray server +回落流程:WEB client <--------------- HTTP/2或HTTPS ---------------> Xray server <-- H2C或HTTP/1.1 --> Nginx(WEB server) + +注意: + +1、Xray 版本不小于 v1.7.2 才完美支持 VLESS 协议的 XTLS Vision 应用。 + +2、Nginx 支持 H2C server 需要 Nginx 包含 http_v2_module 模块。 + +3、Nginx 支持 H2C server,但不支持 HTTP/1.1 server 与 H2C server 共用一个端口或一个进程;故回落分成 http/1.1 回落与 h2 回落分别对应 Nginx 的 HTTP/1.1 server 与 H2C server。 + +4、Nginx 支持请求标头还原为真实客户端地址需要 Nginx 包含 http_realip_module 模块。 + +5、不要使用 ACME 客户端在采用本示例的服务器上以 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书,因 HTTP-01 或 TLS-ALPN-01 验证方式申请与更新 TLS 证书需监听 80 或 443 端口,从而与当前应用端口冲突。 + +6、配置1:使用 Local Loopback 连接,且启用了 PROXY protocol。配置2:使用 UDS 连接,且启用了 PROXY protocol。