科学上网

零基础保姆级小白节点搭建教学,目前最安全最稳定的搭建方式,通过x-ui面板实现单端口多用户合租

教程完全零基础手把手教学,只要跟着步骤来一定能成功搭建。
使用X-UI面板搭建vmess+ws+tls+web或者vless+ws+tls+web的节点,这是目前最安全的搭建方式
并且为了更进一步的安全,有些步骤甚至有点繁琐,这都是值得的,只有安全了才能实现省时省心
非常适合想有自己专属稳定的节点又不太愿意折腾的朋友。跳出翻墙出来学翻墙的怪圈。

至于高速稳定只有靠钞能力解决了,作为电信用户的我,刨除高攀不起的专线,个人承受范围内最好的线路是CN2 GIA
本教程使用的是搬瓦工CN2GIA线路,经过了三网优化,电信、移动、联通用户都能获得非常稳定的体验,实现全天稳定丝滑的科学上网体验,告别晚高峰拥堵的情况
考虑到GIA线路比较贵,最后给大家提供一种使用x-ui面板通过WS路径分流实现单端口多用户的合租方案,可以和你的朋友合租来分摊费用

VPS购买

搬瓦工
优惠码: BWHNCXNVXV

系统:Ubuntu22.04

执行unminimize之后,中途如果出现的A new version提示信息,输入数字2,再回车即可

域名购买

namesilo
优惠码:oldtong

SSH工具

FinallShell

方法一:手动搭建

节点搭建

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!!!重要!x-ui不要把xray版本升级到1.7.5以上,否则无法搭建vless节点!
#更新软件源
apt update
#启用 BBR TCP 拥塞控制算法
echo "net.core.default_qdisc=fq" >> /etc/sysctl.conf
echo "net.ipv4.tcp_congestion_control=bbr" >> /etc/sysctl.conf
sysctl -p

#安装x-ui:
bash <(curl -Ls https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh)

#安装nginx
apt install nginx
#安装acme:
curl https://get.acme.sh | sh
#添加软链接:
ln -s /root/.acme.sh/acme.sh /usr/local/bin/acme.sh
#切换CA机构:
acme.sh --set-default-ca --server letsencrypt
#申请证书:
acme.sh --issue -d 你的域名 -k ec-256 --webroot /var/www/html
#安装证书:
acme.sh --install-cert -d 你的域名 --ecc --key-file /etc/x-ui/server.key --fullchain-file /etc/x-ui/server.crt --reloadcmd "systemctl force-reload nginx"

寻找适合的伪装站

http站点优先,个人网盘符合单节点大流量特征

示例关键字:intext:登录 Cloudreve

配置nginx

配置文件路径:/etc/nginx/nginx.conf

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
user www-data;
worker_processes auto;
pid /run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;

events {
worker_connections 1024;
}

http {
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;

include /etc/nginx/mime.types;
default_type application/octet-stream;
gzip on;

server {
listen 443 ssl;

server_name nicename.co; #你的域名
ssl_certificate /etc/x-ui/server.crt; #证书位置
ssl_certificate_key /etc/x-ui/server.key; #私钥位置

ssl_session_timeout 1d;
ssl_session_cache shared:MozSSL:10m;
ssl_session_tickets off;
ssl_protocols TLSv1.2 TLSv1.3;
ssl_prefer_server_ciphers off;

location / {
proxy_pass https://bing.com; #伪装网址
proxy_redirect off;
proxy_ssl_server_name on;
sub_filter_once off;
sub_filter "bing.com" $server_name;
proxy_set_header Host "bing.com";
proxy_set_header Referer $http_referer;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header User-Agent $http_user_agent;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_set_header Accept-Encoding "";
proxy_set_header Accept-Language "zh-CN";
}


location /ray { #分流路径
proxy_redirect off;
proxy_pass http://127.0.0.1:10000; #Xray端口
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

location /xui { #xui路径
proxy_redirect off;
proxy_pass http://127.0.0.1:9999; #xui监听端口
proxy_http_version 1.1;
proxy_set_header Host $host;
}
}

server {
listen 80;
location /.well-known/ {
root /var/www/html;
}
location / {
rewrite ^(.*)$ https://$host$1 permanent;
}
}
}

每次修改nginx配置文件后必须使用 systemctl reload nginx 命令重新加载配置文件

多用户合租

通过修改nginx的配置文件实现ws path路径分流

1
2
3
4
5
6
7
8
9
10
location /ray {   #分流路径
proxy_redirect off;
proxy_pass http://127.0.0.1:10000; #Xray端口
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

MITM节点

服务端配置

1
2
3
4
5
#安装x-ui
bash <(curl -Ls https://raw.githubusercontent.com/vaxilu/x-ui/master/install.sh)

#无域名,生成自签证书
openssl req -new -x509 -nodes -newkey rsa:2048 -keyout /etc/x-ui/ca.key -out /etc/x-ui/ca.crt -subj "/CN=MITM" -days 36500

image-20230531163823796

x-ui模板

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
{
"log": {
"access": "",
"error": "",
"loglevel": "warning"
},
"inbounds": [
{
"port": 443,
"protocol": "vless",
"settings": {
"clients": [
{
"id": "bulianglin"
},
{
"id": "bulianglin-mitm",
"email": "mitm@mitm.com"
}
],
"decryption": "none"
},
"streamSettings": {
"network": "tcp",
"security": "tls",
"tlsSettings": {
"certificates": [
{
"certificateFile": "/etc/x-ui/ca.crt",
"keyFile": "/etc/x-ui/ca.key"
}
]
}
}
}
],
"outbounds": [
{
"protocol": "freedom"
},
{
"tag": "mitm",
"protocol": "freedom",
"streamSettings": {
"security": "tls",
"tlsSettings": {
"alpn": [
"http/1.1"
]
}
}
}
],
"routing": {
"rules": [
{
"user": "mitm@mitm.com",
"outboundTag": "mitm",
"type": "field"
}
]
}
}

客户端配置

xray模板

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
{
"log": {
"access": "",
"error": "",
"loglevel": "warning"
},
"inbounds": [
{
"tag": "socks",
"port": 8888,
"listen": "127.0.0.1",
"protocol": "socks",
"settings": {
"udp": true
},
"sniffing": {
"enabled": true
}
},
{
"tag": "http",
"port": 9999,
"listen": "127.0.0.1",
"protocol": "http",
"sniffing": {
"enabled": true
}
},
{
"listen": "127.0.0.1",
"port": 11111,
"tag": "in-mitm",
"protocol": "dokodemo-door",
"settings": {
"port": 443,
"followRedirect": true
},
"streamSettings": {
"security": "tls",
"tlsSettings": {
"certificates": [
{
"usage": "issue",
"certificateFile": "ca.crt",
"keyFile": "ca.key"
}
],
"alpn": [
"http/1.1"
]
}
}
}
],
"outbounds": [
{
"tag": "proxy",
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "你的服务器ip",
"port": 443,
"users": [
{
"id": "bulianglin",
"encryption": "none",
"flow": ""
}
]
}
]
},
"streamSettings": {
"network": "tcp",
"security": "tls",
"tlsSettings": {
"allowInsecure": true
}
}
},
{
"tag": "out-mitm",
"protocol": "vless",
"settings": {
"vnext": [
{
"address": "你的服务器ip",
"port": 443,
"users": [
{
"id": "bulianglin-mitm",
"encryption": "none",
"flow": ""
}
]
}
]
},
"streamSettings": {
"network": "tcp",
"security": "tls",
"tlsSettings": {
"allowInsecure": true
}
}
},
{
"tag": "direct",
"protocol": "freedom"
},
{
"protocol": "freedom",
"settings": {
"redirect": "127.0.0.1:11111"
},
"tag": "re-entry"
}
],
"routing": {
"domainStrategy": "IPOnDemand",
"domainMatcher": "mph",
"rules": [
{
"type": "field",
"outboundTag": "direct",
"domain": [
"geosite:cn"
]
},
{
"type": "field",
"outboundTag": "direct",
"ip": [
"geoip:private",
"geoip:cn"
]
},
{
"type": "field",
"inboundTag": "in-mitm",
"outboundTag": "out-mitm"
},
{
"type": "field",
"port": "443",
"protocol": "tls",
"outboundTag": "re-entry"
}
]
}
}

新建config.json,粘贴模板,打开v2rayN(6.0以下的版本)文件所在目录,Xray内核和程序在同一目录下,将证书文件和私钥复制到过去,然后在v2rayN中添加自定义配置服务器,随便给个别名,将我们刚才创建的配置文件导入进来,内核选择Xray,点击确定,选中刚才创建的节点,在浏览器中设置代理,可以用配置文件中socks的8888,或者HTTP的9999,尝试访问谷歌,可以看到弹出了不安全的警告信息,这是MITM的正常表现,因为我们现在用的是自己签的ca,证书由于我们还没有信任Xray的根证书颁发机构,所以弹出来警告,尝试访问YouTube,也是同样的警告,接下来需要信任我们的CA证书,双击打开,点击安装证书 存储位置按需选择,我选择当前用户,将证书导入到受信任的根证书颁发机构,导入成功后重启浏览器,此时再来访问谷歌就可以正常访问了,并且消除了TIT的特征,可以看到谷歌的证书是由Xray的自签CA颁发的,我给大家的配置分流规则是,国内网站不走代理,所以百度并没有进行MITM,证书还是正常的证书,只是我们走代理的网站会进行MITM,这就是MITM节点的搭建过程,还是很简单的,如果你不想使用了,强烈建议把刚才导入的CA证书移除受信任,在开始菜单中搜索cer,由于刚才我们是将证书导入到当前用户,所以选择管理用户证书,如果你导入的是本地计算机,就选择下面的管理计算机证书,在受信任的根证书颁发机构里面,找到刚才导入的MITM证书,将其删除即可,删除之后,再重新使用MITM节点访问谷歌,又会弹出安全警告了,这就是MITM节点的搭建方法,我个人是不建议平时用这种方式进行科学上网的,因为你无法保证你的VPS绝对安全,当然具体还是得看你自己,毕竟每个人对安全都有自己不同的标准

naive节点

naive服务端配置

编译安装caddy+naive:

1
2
3
4
5
6
7
8
9
10
apt install software-properties-common
add-apt-repository ppa:longsleep/golang-backports
apt update
apt install golang-go

#测试
go version

go install github.com/caddyserver/xcaddy/cmd/xcaddy@latest
~/go/bin/xcaddy build --with github.com/caddyserver/forwardproxy@caddy2=github.com/klzgrad/forwardproxy@naive

Caddyfile配置:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
:443, naive.buliang0.tk #你的域名
tls example@example.com #你的邮箱
route {
forward_proxy {
basic_auth user pass #用户名和密码
hide_ip
hide_via
probe_resistance
}
#支持多用户
forward_proxy {
basic_auth user2 pass2 #用户名和密码
hide_ip
hide_via
probe_resistance
}
reverse_proxy https://demo.cloudreve.org { #伪装网址
header_up Host {upstream_hostport}
header_up X-Forwarded-Host {host}
}
}

caddy常用指令:

前台运行caddy:./caddy run
后台运行caddy:./caddy start
停止caddy:./caddy stop
重载配置:./caddy reload

caddy配置守护进程(开机自启):https://github.com/klzgrad/naiveproxy/wiki/Run-Caddy-as-a-daemon

自定义端口:

naive如果要用自定义端口,需要使用json的配置方式,新手可以直接跳过

启动方式:./caddy start --config config.json

config.json内容:

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
//需删除注释内容caddy才能加载
{
"apps": {
"http": {
"servers": {
"srv0": {
"listen": [
":4431" //监听端口
],
"routes": [
{
"handle": [
{
"auth_user_deprecated": "user", //用户名
"auth_pass_deprecated": "pass", //密码
"handler": "forward_proxy",
"hide_ip": true,
"hide_via": true,
"probe_resistance": {}
}
]
},
{
"handle": [
{
"handler": "reverse_proxy",
"headers": {
"request": {
"set": {
"Host": [
"{http.reverse_proxy.upstream.hostport}"
],
"X-Forwarded-Host": [
"{http.request.host}"
]
}
}
},
"transport": {
"protocol": "http",
"tls": {}
},
"upstreams": [
{
"dial": "demo.cloudreve.org:443" //伪装网址
}
]
}
]
}
],
"tls_connection_policies": [
{
"match": {
"sni": [
"naive.buliang0.tk" //域名
]
},
"certificate_selection": {
"any_tag": [
"cert0"
]
}
}
],
"automatic_https": {
"disable": true
}
}
}
},
"tls": {
"certificates": {
"load_files": [
{
"certificate": "/root/a.crt", //公钥路径
"key": "/root/a.key", //私钥路径
"tags": [
"cert0"
]
}
]
}
}
}
}

客户端配置

naive客户端:https://github.com/klzgrad/naiveproxy/releases/latest

客户端配置:

1
2
3
4
{
"listen": "socks://127.0.0.1:1080",
"proxy": "https://user:pass@example.com"
}

使用v2rayN加载naive内核需要将配置文件的log行删除,否则会断流

TLS指纹查看

jarm工具:https://github.com/salesforce/jarm

下载jarm:wget https://raw.githubusercontent.com/salesforce/jarm/master/jarm.py
查看网站jarm指纹:python3 jarm.py naive.buliang0.tk

网络空间资产搜索引擎:https://fofa.info

方法二:脚本搭建

更新软件和安装工具

1
2
3
4
5
#系统centos
yum update -y && yum upgrade -y && yum install curl -y && yum -y install wget

#系统debian
apt update && apt upgrade -y && apt install curl -y && apt -y install wget

安装脚本

一直默认回车就好,碰到y or n 也可以回车

1
wget -P /root -N --no-check-certificate "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh" && chmod 700 /root/install.sh && /root/install.sh

开启BBR加速

选择2 和 11 安装,然后再reboot

1
wget --no-check-certificate -O tcpx.sh https://raw.githubusercontent.com/ylx2016/Linux-NetSpeed/master/tcpx.sh && chmod +x tcpx.sh && ./tcpx.sh