例1:
gogroxy作为tcp反向代理使用,需要一台具有公网IP地址的服务器,公网服务器和内网服务器在内网网络上是联通的。通过goproxy将内网服务器的内部端口,在公网服务器上暴露出来。
gogroxy软件网站:“https://github.com/snail007/goproxy”,软件使用golang开发,支持跨平台。可下载各类操作系统的binary版本。
例1:在公网服务器上运行如下命令,公网服务器端口“33080”,内网服务器地址和端口“192.168.2.251:3000”
[sudaobo@testsvr252 goproxy]$ ./proxy tcp -p ":33080" -T tcp -P "192.168.2.251:3000"
######## ######## ####### ## ## ## ##
## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ####
######## ######## ## ## ### ##
## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ##
## ## ## ####### ## ## ##
v5.3 by snail , blog : http://www.host900.com/
2018/08/21 11:18:19 use tcp parent 192.168.2.251:3000
2018/08/21 11:18:19 tcp proxy on [::]:33080
2018/08/21 11:18:41 conn 192.168.10.242:21793 - 192.168.2.251:3000 connected
2018/08/21 11:18:41 conn 192.168.10.242:21794 - 192.168.2.251:3000 connected
2018/08/21 11:18:41 conn 192.168.10.242:21795 - 192.168.2.251:3000 connected
2018/08/21 11:18:41 conn 192.168.10.242:21796 - 192.168.2.251:3000 connected
2018/08/21 11:19:58 conn 192.168.10.242:21795 - 192.168.2.251:3000 released
2018/08/21 11:19:58 conn 192.168.10.242:21796 - 192.168.2.251:3000 released
2018/08/21 11:20:13 conn 192.168.10.242:21838 - 192.168.2.251:3000 connected
2018/08/21 11:20:13 conn 192.168.10.242:21839 - 192.168.2.251:3000 connected
2018/08/21 11:20:21 conn 192.168.10.242:21844 - 192.168.2.251:3000 connected
2018/08/21 11:20:21 conn 192.168.10.242:21845 - 192.168.2.251:3000 connected
^C2018/08/21 11:22:09 Received an interrupt, stopping services...
2018/08/21 11:22:09 accept error , ERR:accept tcp [::]:33080: use of closed network connection
2018/08/21 11:22:09 conn 192.168.10.242:21838 - 192.168.2.251:3000 released
2018/08/21 11:22:09 conn 192.168.10.242:21844 - 192.168.2.251:3000 released
2018/08/21 11:22:09 conn 192.168.10.242:21845 - 192.168.2.251:3000 released
2018/08/21 11:22:09 conn 192.168.10.242:21839 - 192.168.2.251:3000 released
2018/08/21 11:22:09 conn 192.168.10.242:21793 - 192.168.2.251:3000 released
例2:在公网服务器上运行如下命令,公网服务器端口“5500”,内网服务器地址和端口“192.168.2.251:5500”
[sudaobo@testsvr252 goproxy]$ ./proxy tcp -p ":5500" -T tcp -P "192.168.2.251:5500"
######## ######## ####### ## ## ## ##
## ## ## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ## ####
######## ######## ## ## ### ##
## ## ## ## ## ## ## ##
## ## ## ## ## ## ## ##
## ## ## ####### ## ## ##
v5.3 by snail , blog : http://www.host900.com/
2018/08/21 11:22:27 use tcp parent 192.168.2.251:5500
2018/08/21 11:22:27 tcp proxy on [::]:5500
2018/08/21 11:24:31 conn 122.97.179.236:54428 - 192.168.2.251:5500 connected
2018/08/21 11:27:17 conn 122.97.179.236:54428 - 192.168.2.251:5500 released
2018/08/21 11:27:20 conn 122.97.179.236:54429 - 192.168.2.251:5500 connected