Skip to main content

国内VPS搭建xray翻墙回国节点

国内 VPS 访问 github 超级慢,用上一话的教程搭建 xray 不太快,所以新话如下。

环境
  • 适用于国内的 VPS

直接下载编译好的 xray#

  • 短链接方便记住
apt update;
apt install unzip -y
wget -O /tmp/xray-linux.zip https://u.huhu.blue/xray.zip;
unzip /tmp/xray-linux.zip -d /tmp;
cp /tmp/xray /usr/local/bin;
chmod +x /usr/local/bin/xray;

xray 配置文件#

  • xray 支持机读 json 、人读toml yaml格式

  • xraytroajn 公用 443 端口的服务器端配置如下

danger

服务器默认不开通80,8080,443端口 不支持IP直接访问,需进行网站(新增或接入)备案。 没有"域名过白"操作,不接受其他运营商的备案信息

VlessAndTrojan




{
"log": {
"loglevel": "info"
},
"inbounds": [
{
"port": "443",
"protocol": "vless",
"settings": {
"clients": [
{
"id": "8f1d333f-3722-4a28-9964-afefc9ffb6b3",
"flow": "xtls-rprx-direct"
}
],
"decryption": "none",
"fallbacks": [
{
"dest": 55555,
"xver": 1
}
]
},
"streamSettings": {
"network": "tcp",
"security": "xtls",
"xtlsSettings": {
"alpn": [
"http/1.1"
],
"certificates": [
{
"certificateFile": "/etc/letsencrypt/live/demo.none.blue/fullchain.pem",
"keyFile": "/etc/letsencrypt/live/demo.none.blue/privkey.pem"
}
]
}
}
},
{
"port": 55555,
"listen": "127.0.0.1",
"protocol": "trojan",
"settings": {
"clients": [
{
"password": "!@#$%^&*()"
}
],
"fallbacks": [
{
"dest": 80
}
]
},
"streamSettings": {
"network": "tcp",
"security": "none",
"tcpSettings": {
"acceptProxyProtocol": true
}
}
}
],
"outbounds": [
{
"protocol": "freedom"
}
]
}

mkdir -p /etc/xray;cat <<EOF > /etc/xray/serve.json
{"log":{"loglevel":"info"},"inbounds":[{"port":"443","protocol":"vless","settings":{"clients":[{"id":"8f1d333f-3722-4a28-9964-afefc9ffb6b3","flow":"xtls-rprx-direct"}],"decryption":"none","fallbacks":[{"dest":55555,"xver":1}]},"streamSettings":{"network":"tcp","security":"xtls","xtlsSettings":{"alpn":["http/1.1"],"certificates":[{"certificateFile":"/etc/letsencrypt/live/demo.none.blue/fullchain.pem","keyFile":"/etc/letsencrypt/live/demo.none.blue/privkey.pem"}]}}},{"port":55555,"listen":"127.0.0.1","protocol":"trojan","settings":{"clients":[{"password":"!@#$%^&*()"}],"fallbacks":[{"dest":80}]},"streamSettings":{"network":"tcp","security":"none","tcpSettings":{"acceptProxyProtocol":true}}}],"outbounds":[{"protocol":"freedom"}]}
EOF

申请证书#

  • 安装 certbot

  • 解析域名添加记录

  • 根据提示再添加 txt 记录

cd;snap install --classic certbot
Certbot
certbot certonly --manual --preferred-challenges dns --register-unsafely-without-email --agree-tos -d none.blue

xray 自启动#

  • 创建 service
cat <<EOF > /etc/systemd/system/xray.service
[Unit]
Description=The Xray proxy server
After=network-online.target
[Service]
ExecStart=/usr/local/bin/xray -c /etc/xray/serve.json
ExecStop=/bin/killall xray
Restart=always
RestartSec=15s
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload;
systemctl enable xray

最后#

  • 启动 xray
systemctl start xray
建议

网站说没就没,注意备份哦。

一个不过分的要求#

YouTube7
mainroutergiftcmsapplegoogleteamviewer