0%

在 ipv6 only 的 vps 搭建代理

在 ipv6 only 的服务器搭建 websocket 代理服务,用 Cloudflare 的 Workers 做反代连接,客户端可自选 Cloudflare CDN 的 ipv4 ip 连接。
因为 Workers 不允许 ip 直连,所以要有一个域名。

SS-Rust 的配置:

1
2
3
4
5
6
7
8
9
10
{
"server":"127.0.0.1", # 如果SS直接对外开放,这里应该改为监听ipv6地址,端口改成443
"server_port":14114,
"password":"",
"method":"none", # 改为不加密,可减轻某些设备的负担
"mode":"tcp_and_udp",
"plugin":"v2ray-plugin",
"plugin_opts":"server;path=/d1145141919810b", # path 应该尽可能长
"dns":"8.8.8.8"
}

Nginx 的配置:

1
2
3
4
5
6
7
8
9
10
11
server {
listen [::]:80;
server_name fakehost.name; # 这里设置为域名
location /d1145141919810b { # 这里的路径要和SS配置里的path一致
proxy_pass http://127.0.0.1:14114; # 设置SS监听的地址
proxy_redirect off;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $http_host;
}
}

Workers 的配置:

1
2
3
4
5
6
7
8
9
10
11
addEventListener("fetch", event => {
event.respondWith(
fetch(
new Request(
"http://fakehost.name/d1145141919810b",
event.request
)
)
)
})

配置好后,客户端的 address 可以用自选 Cloudflare CDN 的 ipv4 ip,port 填 443,连接模式选 tls,hostname 填 Workers 获得的 host,path 随意。