Debian
1、开启bbr
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control = bbr" >>/etc/sysctl.conf
echo "net.core.default_qdisc = fq" >>/etc/sysctl.conf
sysctl -p >/dev/null 2>&12、安装xray
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install# 更新 geodata
bash -c "$(curl -L https://github.com/XTLS/Xray-install/raw/main/install-release.sh)" @ install-geodata3、生成x25519公钥和私钥
xray x255194、生成uuid
xray uuid5、编辑配置文件/usr/local/etc/xray/config.json
{ // VLESS + Reality
"log": {
"loglevel": "warning"
},
"inbounds": [
{
"listen": "0.0.0.0",
"port": 443, // 可更改
"protocol": "vless",
"settings": {
"clients": [
{
"id": "你的UUID", // ***改这里
"flow": "xtls-rprx-vision"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "tcp",
"security": "reality",
"realitySettings": {
"show": false,
"dest": "你喜欢的网站:443", // ***如 learn.microsoft.com:443
"xver": 0,
"serverNames": ["你喜欢的网站"], //***如 learn.microsoft.com
"privateKey": "你的**私钥**", // ***改这里
"shortIds": [""] // 可以留空
}
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
}
],
"outbounds": [
{
"protocol": "freedom",
"tag": "direct"
},
{
"protocol": "blackhole",
"tag": "block"
}
],
"dns": {
"servers": [
"8.8.8.8",
"1.1.1.1",
"2001:4860:4860::8888",
"2606:4700:4700::1111",
"localhost"
]
},
"routing": {
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"type": "field",
"ip": ["geoip:private"],
"outboundTag": "block"
}
]
}
}6、重启xray
service xray restartalpine
1、开启bbr
sed -i '/net.ipv4.tcp_congestion_control/d' /etc/sysctl.conf
sed -i '/net.core.default_qdisc/d' /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control = bbr" >>/etc/sysctl.conf
echo "net.core.default_qdisc = fq" >>/etc/sysctl.conf
sysctl -p >/dev/null 2>&12、安装依赖
apk update
apk add bash curl wget unzip ca-certificates tzdata3、安装xray
# 创建目录
mkdir -p /usr/local/bin /usr/local/etc/xray
# 下载并解压最新版 Xray
wget https://github.com/XTLS/Xray-core/releases/latest/download/Xray-linux-64.zip
unzip Xray-linux-64.zip xray -d /usr/local/bin/
# 赋予执行权限并清理压缩包
chmod +x /usr/local/bin/xray
rm Xray-linux-64.zip4、生成公私钥、uuid
xray x25519
xray uuid5、编辑配置文件/usr/local/etc/xray/config.json
{ // VLESS + Reality
"log": {
"loglevel": "warning"
},
"inbounds": [
{
"listen": "0.0.0.0",
"port": 443, // 可更改
"protocol": "vless",
"settings": {
"clients": [
{
"id": "你的UUID", // ***改这里
"flow": "xtls-rprx-vision"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "tcp",
"security": "reality",
"realitySettings": {
"show": false,
"dest": "你喜欢的网站:443", // ***如 learn.microsoft.com:443
"xver": 0,
"serverNames": ["你喜欢的网站"], //***如 learn.microsoft.com
"privateKey": "你的**私钥**", // ***改这里
"shortIds": [""] // 可以留空
}
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
}
],
"outbounds": [
{
"protocol": "freedom",
"tag": "direct"
},
{
"protocol": "blackhole",
"tag": "block"
}
],
"dns": {
"servers": [
"8.8.8.8",
"1.1.1.1",
"2001:4860:4860::8888",
"2606:4700:4700::1111",
"localhost"
]
},
"routing": {
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"type": "field",
"ip": ["geoip:private"],
"outboundTag": "block"
}
]
}
}6、编写OpenRC守护进程
cat << 'EOF' > /etc/init.d/xray
#!/sbin/openrc-run
name="xray"
description="Xray Core Service"
command="/usr/local/bin/xray"
command_args="run -config /usr/local/etc/xray/config.json"
command_background="yes"
pidfile="/run/${name}.pid"
output_log="/var/log/xray.log"
error_log="/var/log/xray.err"
depend() {
need net
}
EOF7、启动并设置开机自启,下载规则并重启
# 赋予脚本执行权限
chmod +x /etc/init.d/xray
# 设置开机自启
rc-update add xray defaultcd /usr/local/bin/ && \
wget -O geoip.dat https://github.com/v2fly/geoip/releases/latest/download/geoip.dat && \
wget -O geosite.dat https://github.com/v2fly/domain-list-community/releases/latest/download/dlc.dat && \
rc-service xray restartshortid可空
# 启动服务
rc-service xray start
# 查看运行状态
rc-service xray status
#查看xray报错
/usr/local/bin/xray run -config /usr/local/etc/xray/config.json四个推荐的 dest 站点
评论区