Repository navigation
这是最后一个使用 SSG 打包的版本
使用方式
解压静态文件,由于 zerotier binary 不对跨域做正确处理且只接受来自 localhost 的请求,需要使用 caddy 或 nginx 同时解决托管网站和跨域问题
参考此配置使用 caddy 承载
{
"admin":{
"disabled":true
},
"apps": {
"http": {
"servers": {
"ztocp": {
"listen": ["0.0.0.0:9994"],
"routes": [
{
"match":[
{
"path":["/zerotier/*"]
}
],
"handle":[
{
"handler":"authentication",
"providers":{
"http_basic":{
"hash":{
"algorithm": "bcrypt"
},
"accounts":[
{"username":"username","password":"$2a$10$egkd8sE7eGclIohEJBYYr.9Ck3KKN2Zgiq7/7WpFUY/Ats.Mzt9ja","salt":""}
]
}
}
},{
"handler": "reverse_proxy",
"transport":{
"protocol":"http",
"keep_alive":{
"enabled":true,
"probe_interval":30,
"max_idle_conns":2
}
},
"upstreams":[
{"dial":"127.0.0.1:9993"}
],
"headers":{
"request":{
"add":{
"X-ZT1-AUTH":["cgaydu2bb86joooaz8qwyj5p"]
}
}
},
"rewrite":{
"strip_path_prefix":"/zerotier"
}
}
]
},{
"match":[
{
"path":["*"]
}
],
"handle":[
{
"handler":"authentication",
"providers":{
"http_basic":{
"hash":{
"algorithm": "bcrypt"
},
"accounts":[
{"username":"username","password":"$2a$10$egkd8sE7eGclIohEJBYYr.9Ck3KKN2Zgiq7/7WpFUY/Ats.Mzt9ja","salt":""}
]
}
}
},{
"handler": "file_server",
"root":"/website/",
"index_names":["index.html"],
"canonical_uris":true,
"precompressed":{"br":{},"zstd":{},"gzip":{"level":1}}
}
]
}
],
"automatic_https":{
"disable":true
}
}
}
}
}
}或参考此配置使用 nginx 承载,注意 auth_basic_user_file 需要自行生成
upstream upstream-zerotier {
server 127.0.0.1:9993;
keepalive 3;
}
server {
listen 9994;
server_name _;
root /website/;
gzip on;
auth_basic authorize;
auth_basic_user_file /path/to/passwd;
location /zerotier/ {
proxy_http_version 1.1;
proxy_pass http://upstream-zerotier/;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Connection '';
}
location / {
# 如果放在外面似乎会导致 /zerotier/ 的路由不正常
index index.html;
}
}