Youtube:
https://youtu.be/TleF1xwK61U
#安装xray
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install -u root
#xray配置文件路径
/usr/local/etc/xray/config.json
#xray配置文件
{ "log": { "loglevel": "warning" }, "routing": { "domainStrategy": "IPIfNonMatch", "rules": [ { "type": "field", "port": "443", "network": "udp", "outboundTag": "block" }, { "type": "field", "ip": [ "geoip:cn", "geoip:private" ], "outboundTag": "block" } ] }, "inbounds": [ { "listen": "0.0.0.0", "port": 443, "protocol": "vless", "settings": { "clients": [ { "id": "", // run `xray uuid` to generate "flow": "xtls-rprx-vision" } ], "decryption": "none" }, "streamSettings": { "network": "tcp", "security": "reality", "realitySettings": { "show": false, "dest": "8003", "xver": 1, "serverNames": [ "" // server name ], "privateKey": "", // run `xray x25519` to generate "shortIds": [ "" // 0 to f, length is a multiple of 2, maximum length is 16 ] } }, "sniffing": { "enabled": true, "destOverride": [ "http", "tls", "quic" ] } } ], "outbounds": [ { "protocol": "freedom", "tag": "direct" }, { "protocol": "blackhole", "tag": "block" } ], "policy": { "levels": { "0": { "handshake": 2, "connIdle": 120 } } } }
#检查xray配置
xray -test -config /usr/local/etc/xray/config.json
#重启xray并查看xray运行情况
systemctl restart xray && systemctl status xray
#安装 caddy
apt install -y sudo debian-keyring debian-archive-keyring apt-transport-https curl && curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/gpg.key' | sudo gpg --dearmor -o /usr/share/keyrings/caddy-stable-archive-keyring.gpg && curl -1sLf 'https://dl.cloudsmith.io/public/caddy/stable/debian.deb.txt' | tee /etc/apt/sources.list.d/caddy-stable.list && apt update && apt install caddy
#默认配置文件目录
/etc/caddy/caddy.json
#caddy配置文件
{ "apps": { "http": { "servers": { "srvh1": { "listen": [":80"], "routes": [{ "handle": [{ "handler": "static_response", "headers": { "Location": ["https://{http.request.host}{http.request.uri}"] }, "status_code": 301 }] }], "protocols": ["h1"] }, "srvh2": { "listen": ["127.0.0.1:8003"], "listener_wrappers": [{ "wrapper": "proxy_protocol", "allow": ["127.0.0.1/32"] }, { "wrapper": "tls" }], "routes": [ { "handle": [{ "handler": "headers", "response": { "set": { "Strict-Transport-Security": ["max-age=31536000; includeSubDomains; preload"], "Alt-Svc": ["h3=\":443\"; ma=2592000"] } } }, { "handler": "reverse_proxy", "transport": { "protocol": "http", "tls": {} }, "upstreams": [{ "dial": "xx.com:443" //伪装网站 }], "headers": { "request": { "set": { "Host": ["{http.reverse_proxy.upstream.hostport}"] } } } }] }], "tls_connection_policies": [{ "match": { "sni": ["yourdomain.com"] //你的域名 }, "cipher_suites": ["TLS_ECDHE_ECDSA_WITH_AES_256_GCM_SHA384", "TLS_ECDHE_ECDSA_WITH_AES_128_GCM_SHA256", "TLS_ECDHE_ECDSA_WITH_CHACHA20_POLY1305_SHA256"], "curves": ["x25519", "secp521r1", "secp384r1", "secp256r1"], "alpn": ["h3", "h2", "http/1.1"] }], "protocols": ["h1", "h2", "h3"] } } }, "tls": { "certificates": { "automate": ["yourdomain.com"] //你的域名 }, "automation": { "policies": [{ "issuers": [{ "module": "acme", "email": "[email protected]" }] }] } } } }
#测试配置文件
caddy validate --config /etc/caddy/caddy.json
#启动服务端
caddy run --config /etc/caddy/caddy.json
//得到“certificate obtained successfully ” “releasing lock”
#80或者2019占用
caddy stop
再启动
#关闭caddy
ctrl+c
#后台运行caddy:
caddy start --config /etc/caddy/caddy.json
caddy常用指令:
前台运行caddy:
caddy run
后台运行caddy:
caddy start
停止caddy:
caddy stop
重载配置:
caddy reload
相关导航
暂无评论...