1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200
| mkdir -p /home/user/proxy-tools/xray mkdir -p /home/user/proxy-tools/hysteria2 mkdir -p /home/user/proxy-tools/hysteria2/masquerade
wget https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-64.zip -O /home/user/proxy-tools/xray/Xray-linux-64.zip wget https://github.com/apernet/hysteria/releases/latest/download/hysteria-linux-amd64 -O /home/user/proxy-tools/hysteria2/hysteria2 wget https://www.rfc-editor.org/rfc/rfc1178 -O /home/user/proxy-tools/hysteria2/masquerade/index.html # 网络问题加速下载 # wget https://fastly.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geoip.dat -O /home/user/proxy-tools/hysteria2/geoip.dat # wget https://fastly.jsdelivr.net/gh/Loyalsoldier/v2ray-rules-dat@release/geosite.dat -O /home/user/proxy-tools/hysteria2/geosite.dat
unzip /home/user/proxy-tools/xray/Xray-linux-64.zip -d /home/user/proxy-tools/xray rm /home/user/proxy-tools/xray/Xray-linux-64.zip chmod +x /home/user/proxy-tools/xray/xray chmod +x /home/user/proxy-tools/hysteria2/hysteria2
# 别忘记修改password # 按需修改其他参数 # 如果访问某些网站存在异常, 可能是 acl 规则的问题 cat << 'EOF' > /home/user/proxy-tools/hysteria2/config.yaml listen: 0.0.0.0:20443
tls: cert: /home/user/acme-certs/fullchain.pem key: /home/user/acme-certs/key.pem sniGuard: strict
auth: type: password password: random-uuid
acl: inline: - reject(geoip:cn) - reject(geosite:cn) - reject(geosite:category-ads-all) - reject(geoip:private) - reject(geosite:private) # geoip: /home/user/proxy-tools/hysteria2/geoip.dat # geosite: /home/user/proxy-tools/hysteria2/geosite.dat geoUpdateInterval: 24h
masquerade: type: file file: dir: /home/user/proxy-tools/hysteria2/masquerade listenHTTPS: 0.0.0.0:20443 EOF cd /home/user/proxy-tools/hysteria2 && \ nohup ./hysteria2 server -c ./config.yaml > ./hysteria2.log 2>&1 &
touch /home/user/proxy-tools/xray/access.log touch /home/user/proxy-tools/xray/error.log cat << 'EOF' > /home/user/proxy-tools/xray/config.json { "log": { "access": "/home/user/proxy-tools/xray/access.log", "error": "/home/user/proxy-tools/xray/error.log", "loglevel": "info", "dnsLog": true }, "dns": { "servers": [ "https+local://1.1.1.1/dns-query", "localhost" ] }, "routing": { "domainStrategy": "IPIfNonMatch", "rules": [ { "ip": [ "geoip:cn" ], "outboundTag": "block" }, { "domain": [ "geosite:cn" ], "outboundTag": "block" }, { "domain": [ "geosite:category-ads-all" ], "outboundTag": "block" }, { "ip": [ "geoip:private" ], "outboundTag": "block" }, { "domain": [ "geosite:private" ], "outboundTag": "block" } ] }, "inbounds": [ { "listen": "0.0.0.0", "port": 22443, "protocol": "vless", "settings": { "clients": [ { "id": "run [xray uuid]", "flow": "xtls-rprx-vision" } ], "decryption": "run [xray vlessenc]" }, "streamSettings": { "network": "tcp", "security": "tls", "tlsSettings": { "serverName": "[your-domain]", "rejectUnknownSni": true, "minVersion": "1.3", "certificates": [ { "certificateFile": "/home/user/acme-certs/fullchain.pem", "keyFile": "/home/user/acme-certs/key.pem" } ] } }, "sniffing": { "enabled": true, "destOverride": [ "http", "tls" ] } }, { "listen": "0.0.0.0", "port": 23443, "protocol": "vless", "settings": { "clients": [ { "id": "run [xray uuid]", "flow": "" } ], "decryption": "run [xray vlessenc]" }, "streamSettings": { "network": "xhttp", "xhttpSettings": { "path": "[/your-path]" }, "security": "reality", "realitySettings": { "target": "[other-domain]:443", "serverNames": [ "run [xray tls ping other-domain]" ], "privateKey": "run [xray x25519]", "shortIds": [ "[random 0-f string length 16]" ] } }, "sniffing": { "enabled": true, "destOverride": [ "http", "tls", "quic" ] } } ], "outbounds": [ { "tag": "direct", "protocol": "freedom" }, { "tag": "block", "protocol": "blackhole" } ] } EOF cd /home/user/proxy-tools/xray && \ nohup ./xray run -c ./config.json > ./xray.log 2>&1 &
# TODO: # 添加 xray 配置 # 添加防火墙配置 # /home/user/acme-reloadcmd.sh 添加 xray, hysteria2 重启命令 # 添加 xray, hysteria2 定期检查更新脚本 # 添加系统定期更新脚本
|