是否可以使用 spring cloud starter zuul 进行端口转发?
Is it possible port forwarding with spring cloud starter zuul?
关于spring cloud starter zuul,我们可以通过以下配置路由请求路径:
application.yml
server:
port: 80
zuul:
routes:
amqp:
url: http://127.0.0.1:8010/amqp
astm:
url: http://127.0.0.1:8011/astm
mllp:
url: http://127.0.0.1:8012/mllp
labs:
url: http://127.0.0.1:8013/labs
使用来自 http://127.0.0.1/mllp routed to http://127.0.0.1:8012/mllp 的配置请求。但是我想用它做端口转发,有可能吗?让我们说:
============================================
request forwarded
tcp ip:port tcp ip:port
============================================
0.0.0.0:22210 192.168.0.10:22210
0.0.0.0:55510 192.168.0.11:55510
============================================
如果可以怎么配置呢?或者 spring 启动应用程序中用于端口转发的任何简单机制?
您的意思是作为某种运行服务不可知的 HAProxy 替代品?那么答案是:没有!正如您从 Zuul Wiki its only purpose is to filter and route HttpRequests and HttpResponses. You'll also find out the same by checking the code of ZuulServlet
中看到的那样,它只处理 HttpServletRequest
s 和 HttpServletResponse
s。
关于spring cloud starter zuul,我们可以通过以下配置路由请求路径:
application.yml
server:
port: 80
zuul:
routes:
amqp:
url: http://127.0.0.1:8010/amqp
astm:
url: http://127.0.0.1:8011/astm
mllp:
url: http://127.0.0.1:8012/mllp
labs:
url: http://127.0.0.1:8013/labs
使用来自 http://127.0.0.1/mllp routed to http://127.0.0.1:8012/mllp 的配置请求。但是我想用它做端口转发,有可能吗?让我们说:
============================================
request forwarded
tcp ip:port tcp ip:port
============================================
0.0.0.0:22210 192.168.0.10:22210
0.0.0.0:55510 192.168.0.11:55510
============================================
如果可以怎么配置呢?或者 spring 启动应用程序中用于端口转发的任何简单机制?
您的意思是作为某种运行服务不可知的 HAProxy 替代品?那么答案是:没有!正如您从 Zuul Wiki its only purpose is to filter and route HttpRequests and HttpResponses. You'll also find out the same by checking the code of ZuulServlet
中看到的那样,它只处理 HttpServletRequest
s 和 HttpServletResponse
s。