zanjie1999 / tcp-over-websocket

将TCP/UDP放到WebSocket中传输(就能走CDN)基于ws的内网穿透 隧道代理 tcp2ws 全平台0依赖
291 stars 52 forks source link

server模式启动时,能否自动探测内网地址,方便ws反代用在容器环境时 #10

Closed manaphp closed 6 months ago

manaphp commented 1 year ago

./tcp2ws 22 50022

Proxy with Nginx: location /ws/ { proxy_pass http://192.168.1.2:50022/; proxy_read_timeout 3600; proxy_http_version 1.1; proxy_set_header Upgrade $http_upgrade; proxy_set_header Connection "Upgrade"; proxy_set_header X-Forwarded-For $remote_addr; access_log off; }

zanjie1999 commented 1 year ago

我懒,所以他只会显示0.0.0.0,欢迎pr,但请注意需要全平台兼容
其实Linux完全可以用 ip address 配合 grep 或是 awk 实现你这个需求 举个例子 ip addr | grep inet | awk '{print($2)}'