This topic created in 3609 days ago, the information mentioned may be changed or developed.
业务背景:
在内网主机 centos , IP10.10.10.10 ,下载了一个软件 [就一个文件] ,启用服务后有个管理 web ,地址为 127.0.0.1:4040
curl 127.0.0.1:4040 正常。
实现一个小目标:
但是我办公机想访问这个 4040 端口就为难了,然后想到了 nginx 代理可以做。那么想问下 nc 是否可以做呢?
4 replies • 2017-01-16 13:12:42 +08:00
 |
|
lhbcJan 16, 2017 via iPhone 1
1
nginx, iptables, nc 都可以。 哪个熟悉就用哪个吧, iptables 最简单。
|
 |
|
iptables 最简单了 一条命令搞定
tcp 协议的话 haproxy 也简单 你这个需求 nginx 也没问题
nc 一般不是这么用的啦- - 临时用用的
|
 |
|
如果你有 root 权限,可以用 iptables : iptables -t nat -I PREROUTING -i eth0 -p TCP --dport 4040 -j DNAT --to-destination :4040
如果没有 root 权限,可以用 socat : socat TCP-LISTEN:4040,reuseaddr,fork TCP:localhost:4040
|
 |
|
@ lhbc @ Showfom @ kaneg 感谢各位,以前知道 nc 可以反弹 shell ,端口监听,以为可以一条命令完成需求,后来百度了下,还是用的 socat 比较方便
|