版权声明:转载请注明出处 https://blog.csdn.net/cowbin2012/article/details/85298975
其它netty文件有博客
netty实现反向代理(内网穿透)
这里就不贴源码了,主要讲讲如何使用。需要源码可以到码云下载。
一共需要两个服务(proxy-server[服务端],proxy-client[客户端])
proxy-server
配置
---application.yml(文件)
spring.profiles.active: proxyserver
---application-proxyserver.yml(文件)
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
netty.proxy-server.port:用来提供给客户端建立连接
netty.proxy-server.client-server: 端口和服务器映射(以8110为例,用户访问8110端口时,会把请求转发给客户端,告诉客户端请求47.126.126.53的22,达到内网穿透的效果)
proxy-client
配置
---application.yml(文件)
spring.profiles.active: proxyclient
---application-proxyclient.yml(文件)
netty:
proxy-client:
enabled: true
proxy-server: 127.0.0.1:9562
proxy-keys: 123
netty.proxy-client. proxy-server : 为服务端的IP地址和端口(netty.proxy-server.port)