使用 nginx + ipv6 实现内网穿透
2025-02-22 16:21:42
以前,内网穿透我使用的是 frp,运行很稳定,最近发现我的 vps 有 ipv6 了,这样子通过 ipv6 就能实现穿透了。
安装 nginx-full
Ubuntu 下,nginx 默认无 stream 支持,需要安装 nginx-full
sudo apt install nginx-full
配置 nginx
修改 /etc/nginx/nginx.conf 添加
nginx tcp 反代
添加配置:pi.stream
添加配置:pi-ssh.stream
需要注意的是,proxy_connect_timeout 指的是:与后端服务器建立连接的超时时间,而 proxy_timeout 指的是:代理连接的数据传输超时时间;proxy_timeout nginx 官网的解释 是:
Sets the timeout between two successive read or write operations on client or proxied server connections. If no data is transmitted within this time, the connection is closed.
以上面 pi-ssh 为例,如果 proxy_timeout 设置为 10s,那么 ssh 连接在空闲 10s 后就会关闭,虽然 ssh 可配置探活,但探活我配置的是每隔 30s 1 次,最多 120 次,由于 30s 是大于 10s 的,所以会空闲 10s 后断开;
最后更新于