源码地址
springboot2教程系列
其它netty文件有博客
Springboot2(24)集成netty实现http服务(类似SpingMvc的contoller层实现)
Springboot2(25)集成netty实现文件传输
Springboot2(26)集成netty实现websocket通讯
netty实现反向代理(内网穿透)
这里就不贴源码了,主要讲讲如何使用。需要源码可以到码云下载。
一共需要两个服务(proxy-server[服务端],proxy-client[客户端])
proxy-server
配置
---(文件)
: proxyserver
---(文件)
netty:
proxy-server:
enabled: true
port: 9562
client-server:
- port: 8110
bind: 47.126.126.53:22
keys: 123
- port: 8220
bind: 127.0.0.1:1999
keys: 123
- port: 8230
bind: 47.126.126.53:9050
keys: 123
:用来提供给客户端建立连接
-server: 端口和服务器映射(以8110为例,用户访问8110端口时,会把请求转发给客户端,告诉客户端请求47.126.126.53的22,达到内网穿透的效果)
proxy-client
配置
---(文件)
: proxyclient
---(文件)
netty:
proxy-client:
enabled: true
proxy-server: 127.0.0.1:9562
proxy-keys: 123
-client. proxy-server : 为服务端的IP地址和端口()