服务器购买推荐 搬瓦工

  1. 作者的搬瓦工注册邀请链接:
    https://bandwagonhost.com/aff.php?aff=74713&register=true
  2. 购买链接:
    https://bandwagonhost.com/aff.php?aff=74713
  3. 注意选洛杉矶USCA_9机房,这里使用的是cn2gia高端线路,国内访问更稳定。
  4. 选择想要的套餐,order -> add to cart -> checkout (付款需要登录) # 优惠码是 NODESEEK2026 不过好像失效了
  5. 访问云服务器链接:点击设置 -> open kivivm 进入对应云主机管理页面
    https://bwh81.net/services
  6. 初始化应该需要 mount ios ,也就是安装操作系统镜像,推荐 debian 12 吧。
  7. 管理页面可以设置自己的 root 密码,也可以直接点击 root shell - basic 进入root模式的命令行界面。

服务器基础配置

防火墙

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 基础软件
apt install git vim
## 防火墙设置, Azure 这种防火墙由服务商管理的,不用再配置防火墙。shell
apt-get update && apt-get install ufw
ufw enable
ufw status
ufw status verbose

ufw allow 23/tcp # 23 是你的ssh端口号,ssh是tcp协议
ufw allow ssh # 这是开放预设的 22 端口的

ufw allow http #添加80端口

ufw allow https #添加443端口

ssh

ssh 服务器配置: /etc/ssh/sshd_config
改完后 systemctl restart sshd 重启一下sshd服务

1
2
3
4
5
PermitRootLogin yes # 允许root登录
PermitRootLogin prohibit-password # 不允许root密码登录

PubkeyAuthentication yes # 允许秘钥登录
PasswordAuthentication no # 不允许密码登录,如果服务器还有其他用户,可以把其他用户的密码登录也禁用了

ssh 秘钥配置

1
2
3
ssh-keygen -t rsa -b 4096 -C "your_email@example.com" -f ./id_rsa # 生成秘钥
cat id_rsa.pub > ~/.ssh/authorized_keys # 可以使用自己的公钥
chmod 600 ~/.ssh/authorized_keys

其他配置

1
2
3
4
5
6
7
8
9
# 关闭ubuntu的自动更新检查,小机器受不了。
systemctl stop apt-daily.service
systemctl stop apt-daily.timer
systemctl stop apt-daily-upgrade.service
systemctl stop apt-daily-upgrade.timer
systemctl disable apt-daily.service
systemctl disable apt-daily.timer
systemctl disable apt-daily-upgrade.service
systemctl disable apt-daily-upgrade.timer

Dante SOCKS5 代理

简单的 socks5 代理方案。

1
2
3
4
5
6
7
8
9
# install
apt install dante-server
# config
vi /etc/danted.conf
# enable
systemctl start danted
systemctl enable danted
# firewall
ufw allow 1080

Xray 代理

安装

docker 安装

1
2
3
4
5
6
7
docker pull docker.io/teddysun/xray
mkdir -p /work/xray
cd /work/xray
# 此处为配置文件
vi config.json
# 使用9000端口,可自定义端口
docker run -d -p 9000:9000 --name xray --restart=always -v /etc/xray:/etc/xray docker.io/teddysun/xray

主机安装

1
2
3
4
wget https://github.com/XTLS/Xray-install/raw/main/install-release.sh
bash install-release.sh
rm ~/install-release.sh
# 安装后,配置文件在: /usr/local/etc/xray/config.json

网站伪装 可选

1
2
3
4
5
6
7
apt install nginx
mkdir -p /work/www/webpage/
vi /work/www/webpage/index.html
chmod -R a+r /work/www/webpage/
vi /etc/nginx/nginx.conf # 配置xray端口到此网站
# 记得要注释 默认站点
systemctl reload nginx

证书安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# acme 安装
wget -O - https://get.acme.sh | sh
wget https://gitee.com/neilpang/acme.sh/raw/master/acme.sh # 中国大陆使用
. .bashrc
# 自动升级
acme.sh --upgrade --auto-upgrade
# 测试
acme.sh --issue --server https://acme-staging-v02.api.letsencrypt.org/directory --test -d example.com -w /work/www/webpage/ --keylength ec-256

# 安装正式证书
acme.sh --set-default-ca --server letsencrypt
acme.sh --issue -d example.com -w /work/www/webpage/ --keylength ec-256 --force
# dns 方式安装 不需要ip和网站
export Namesilo_Key="Namesilo_Key"
acme.sh --issue --dns dns_namesilo -d example.com -d *.example.com --dnssleep 1800
# 证书安装后秘钥不是可读的,更改权限让其他用户可读
chmod +r /path/to/key
# 官方推荐安装使用(用处不大)
acme.sh --install-cert -d example.com --ecc --fullchain-file /path/to/fullchain --key-file /path/to/key

Xray 配置

配置推荐参考:

1
2
3
4
5
6
# 生成uuid秘钥,用于配置,或者使用debian的uuid
xray uuid

# 这里的 inbounds 的 port 可以随便填一个端口
# 注意给自己的端口开防火墙放行:
ufw allow 你的端口

以下为我的配置参考:

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
{
"log": {
"loglevel": "info",
"access": "/var/log/xray/access.log",
"error": "/var/log/xray/error.log"
},
"dns": {
"servers": [
"172.31.255.2",
"1.1.1.1",
"1.0.0.1"
],
"hosts": {
"hs3434.com": "127.0.0.1",
"hs.com": "127.0.0.1",
"dns.google": [
"8.8.8.8",
"8.8.4.4"
]
}
},
"routing": {
"domainStrategy": "IPIfNonMatch",
"rules": [
{
"type": "field",
"ip": [
"10.0.0.0/8"
],
"outboundTag": "direct"
},
{
"type": "field",
"ip": [
"geoip:private"
],
"outboundTag": "block"
},
{
"type": "field",
"domain": [
"geosite:category-ads-all"
],
"outboundTag": "block"
}
]
},
"inbounds": [
{
"tag": "normal",
"listen": "0.0.0.0",
"port": 443,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "这里填 xray uuid 生成的uuid秘钥",
"flow": "xtls-rprx-vision",
"level": 0,
"email": "guest@example.com"
}
],
"decryption": "none",
"fallbacks": [
{
"dest": "8001",
"xver": 1
},
{
"alpn": "h2",
"dest": "8002",
"xver": 1
}
]
},
"streamSettings": {
"network": "tcp",
"security": "tls",
"tlsSettings": {
"rejectUnknownSni": true,
"minVersion": "1.2",
"certificates": [
{
"ocspStapling": 3600,
"certificateFile": "/work/xray/xray.crt",
"keyFile": "/work/xray/xray.key"
}
]
}
},
"sniffing": {
"enabled": true,
"destOverride": [
"http",
"tls"
]
}
}
],
"outbounds": [
{
"protocol": "freedom",
"tag": "direct"
},
{
"protocol": "blackhole",
"tag": "block"
}
],
"policy": {
"levels": {
"0": {
"handshake": 2,
"connIdle": 400
}
},
"stats": {}

}
}

客户端配置

windows

下载

https://github.com/2dust/v2rayN/
windows版本v2rayN下载链接
https://github.com/2dust/v2rayN/releases/download/7.18.0/v2rayN-windows-64-desktop.zip

mac的版本也有,不过作者没用过mac,就不出教程了
https://github.com/2dust/v2rayN/releases/download/7.18.0/v2rayN-macos-64.dmg

配置

下载后解压,点击 v2rayN.exe 直接启动。
配置项 -> 添加 VLESS 进行配置
主要是 address port id 需要改成自己的自定义设置。

1
2
3
4
5
6
7
8
9
10
address=你的服务器域名地址
port=443
id=xray uuid 生成的uuid秘钥
encryption=none
flow=xtls-rprx-vision
security=tls
alpn=h2%2Chttp
2F1.1&fp=chrome
type=tcp
headerType=none