
nobrand dual 内网 openlist 分享
Dual 有两张网卡,eth0 是日本公网 IP(87.86.x.x),eth1 是沪日专线的内网口(172.16.x.x)。默认路由走 eth0,但 eth1 提供了一条从国内直接进入的专线通道。
整体思路是:本机 HDD 用 OpenList 做成网盘,OpenList 本身只监听 127.0.0.1:5244。公网访问通过 Nginx HTTPS 入口,沪日专线则通过 eth1 的内网 IP 进入 Nginx,再转给本机 OpenList。
安装 OpenList
直接使用官方二进制:
mkdir -p /opt/openlist && cd /opt/openlist
wget -O openlist-linux-amd64.tar.gz https://github.com/OpenListTeam/OpenList/releases/latest/download/openlist-linux-amd64.tar.gz
tar -zxvf openlist-linux-amd64.tar.gz
chmod +x openlist
./openlist version
配置 systemd 服务:
cat >/etc/systemd/system/openlist.service <<'EOF'
[Unit]
Description=OpenList
After=network.target
[Service]
Type=simple
WorkingDirectory=/opt/openlist
ExecStart=/opt/openlist/openlist server
Restart=on-failure
RestartSec=5
[Install]
WantedBy=multi-user.target
EOF
systemctl daemon-reload
systemctl enable --now openlist
OpenList 默认监听 0.0.0.0:5244。初始化阶段可以先通过 http://87.86.x.x:5244 登录后台,把管理员账号和存储配置完成。
配置 HDD 存储
后台进入「存储 → 添加 → 本机存储」。例如 HDD 实际目录为 /data/hdd,可以设置根路径 /data/hdd、挂载路径 /hdd。
建议先通过公网把目录浏览、上传、下载和删除都测试一遍,确认本机存储读写正常,再修改监听方式。
OpenList 改为只监听本机
确认存储没问题后,把 OpenList 从 0.0.0.0 收回到 localhost:
cp /opt/openlist/data/config.json /opt/openlist/data/config.json.bak
sed -i 's/"address": "0.0.0.0"/"address": "127.0.0.1"/' /opt/openlist/data/config.json
systemctl restart openlist
这样 OpenList 本体不再直接暴露在任何网卡上,公网和专线都统一由 Nginx 接入。
配置 Nginx 双入口
公网准备一个域名,例如:
dual.example.com → 87.86.x.x
证书申请过程略。
沪日专线入口直接使用内网 IP 172.16.x.x:5244,公网入口则使用 dual.example.com:443。
cat >/etc/nginx/conf.d/openlist.conf <<'EOF'
server {
listen 87.86.x.x:80;
server_name dual.example.com;
return 301 https://$host$request_uri;
}
server {
listen 172.16.x.x:5244;
server_name _;
allow 172.16.x.x;
deny all;
client_max_body_size 0;
location / {
proxy_pass http://127.0.0.1:5244;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto http;
proxy_request_buffering off;
proxy_buffering off;
proxy_send_timeout 3600s;
proxy_read_timeout 3600s;
}
}
server {
listen 87.86.x.x:443 ssl;
server_name dual.example.com;
ssl_certificate /path/to/fullchain.cer;
ssl_certificate_key /path/to/example.com.key;
client_max_body_size 0;
location / {
proxy_pass http://127.0.0.1:5244;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto https;
proxy_request_buffering off;
proxy_buffering off;
proxy_connect_timeout 60s;
proxy_send_timeout 3600s;
proxy_read_timeout 3600s;
}
}
EOF
nginx -t && systemctl restart nginx
这里沪日入口加了:
allow 172.16.x.x;
deny all;
原因是实际代理连接由本机代理程序发起,Nginx 看到的来源同样是 172.16.x.x。这样即使上海公网入口能够把流量送到这张网卡,也不会直接开放这个 HTTP 入口给其他来源。
最终检查:
ss -lntp | grep -E ':443|:5244'
正常状态应该是:
87.86.x.x:443 → Nginx 公网 HTTPS
172.16.x.x:5244 → Nginx 沪日专线入口
127.0.0.1:5244 → OpenList
专线访问规则
国内客户端给 172.16.x.x/32 单独配置一条走沪日专线的规则,并且放在类似 172.16.0.0/12,DIRECT 这种大范围私网直连规则之前,否则会先被 DIRECT 命中。
这样访问:
http://172.16.x.x:5244/dav/
时,客户端会把连接交给沪日专线代理,由代理在 Dual 本机连接 Nginx,再转给 OpenList。
公网则直接使用:
https://dual.example.com/dav/
不需要额外的专线路由规则。
WebDAV 最终入口
沪日专线:
http://172.16.x.x:5244/dav/
日本公网:
https://dual.example.com/dav/
最终数据路径分别是:
沪日:客户端 → 沪日专线代理 → eth1 → Nginx :5244 → OpenList 127.0.0.1:5244
公网:客户端 → Internet → eth0 → Nginx :443 → OpenList 127.0.0.1:5244
小结
这套方案的重点就是把 Dual 的双网卡真正利用起来。OpenList 本体只监听 localhost,不直接暴露;公网走 eth0 + HTTPS,国内有沪日专线时则直接走 eth1 的内网入口。
同一份 HDD 数据,两条访问路径可以按场景自由选择。人在国内时直接挂沪日专线 WebDAV,可以绕开日本公网回程;需要普通公网访问时,则使用 HTTPS 域名即可。