146 lines
4.5 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

```bash
#/bin/bash
echo "获取公网ip中..."
ip=$(curl -s ipinfo.io/ip)
echo "获取成功,公网地址为 $ip"
echo "是否使用域名是请在10秒内输入该服务器绑定域名否则将使用公网ip"
read -t 10 domain
if [ -z "$domain" ]; then
echo "未输入域名将使用公网IP $ip"
else
echo "使用域名 $domain"
ip="$domain"
fi
echo "倒计时10秒请在此期间输入端口号不输入将使用默认端口50000..."
read -t 10 port
if [ -z "$port" ]; then
port=50000
fi
echo "使用的端口号是: $port"
#更新软件源安装docker、二维码输出工具
apt update && apt install docker.io qrencode
#安装docker-compose
curl -L https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m) -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker-compose --version
docker-compose down
#创建代理文件夹并生成配置文件
mkdir /root/xray && cd /root/xray
cat > docker-compose.yml <<EOF
version: '3.9'
services:
v2ray:
container_name: xray
image: teddysun/xray
ports:
- $port:$port
volumes:
- ./config:/etc/xray/
restart: always
EOF
#生成所需变量
output=$(docker run --rm teddysun/xray /bin/sh -c "xray uuid && xray x25519")
uuid=$(echo "$output" | awk 'NR==1 {print $1}')
privateKey=$(echo "$output" | awk 'NR==2 {print $3}')
publicKey=$(echo "$output" | awk 'NR==3 {print $3}')
shortIDs=$(openssl rand -hex 8)
#生成配置文件
cat > /root/xray/config/config.json <<EOF
{
"log": {
"loglevel": "warning"
},
"routing": {
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"type": "field",
"ip": [
"geoip:cn"
],
"outboundTag": "block"
}
]
},
"inbounds": [
{
"listen": "0.0.0.0",
"port": $port,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "$uuid",
"flow": "xtls-rprx-vision"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "tcp",
"security": "reality",
"realitySettings": {
"show": true, // 若为 true输出调试信息
"dest": "www.lovelive-anime.jp:443", // 目标网站最低标准:国外网站,支持 TLSv1.3、X25519 与 H2域名非跳转用主域名可能被用于跳转到 www
"xver": 0,
"serverNames": [
"www.lovelive-anime.jp"
],
"privateKey": "$privateKey",
"shortIds": [
"$shortIDs"
]
}
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
}
],
"outbounds": [
{
"protocol": "freedom",
"tag": "direct"
},
{
"protocol": "blackhole",
"tag": "block"
}
],
"policy": {
"levels": {
"0": {
"handshake": 2,
"connIdle": 120
}
}
}
}
EOF
#启动容器
docker-compose up -d
#输出导入链接
echo "vless://$uuid@$ip:$port?headerType=none&type=tcp&encryption=none&fp=chrome&pbk=$publicKey&sid=$shortIDs&spx=%2F&flow=xtls-rprx-vision&security=reality&sni=www.lovelive-anime.jp#los-2"
#输出二维码
qrcode="vless://$uuid@$ip:$port?headerType=none&type=tcp&encryption=none&fp=chrome&pbk=$publicKey&sid=$shortIDs&spx=%2F&flow=xtls-rprx-vision&security=reality&sni=www.lovelive-anime.jp#los-2"
qrencode -t ANSIUTF8 "$qrcode"
#输出维护指令
echo "维护时请进入docker-compose.yml所在目录执行以下命令"
echo "重启命令: docker-compose restart"
echo "停止命令: docker-compose down"
echo "启动命令: docker-compose up -d"
echo "查看日志命令: docker-compose logs -f"
echo "查看容器命令: docker-compose ps"
```
# 服务器url
```bash
vless://4d9c1538-2f99-4781-b1fa-8b1cfb67f441@150.109.145.182:50000?headerType=none&type=tcp&encryption=none&fp=chrome&pbk=68Qo5gmZARkxbVw1ArKnCSMw_t8PBGt76e8nnLUPikI&sid=53f9d10d625ba230&spx=%2F&flow=xtls-rprx-vision&security=reality&sni=www.lovelive-anime.jp#los-2
```