如何使用命令行脚本动态配置haproxy? [英] how to dynamically configure haproxy using a command line script?
问题描述
我想知道如何通过命令行脚本自动重新映射运行特定应用程序的URL,例如,正在监听 http://206.189.22.155/designer-api/.
I want to know how I can automatically re-map the url on which a particular app runs via a command line script.For example an app listening on http://206.189.22.155:30000/designer-api/ should be mapped to http://206.189.22.155/designer-api/.
我已经尝试通过在haproxy.conf中添加必要的前端和后端配置来手动映射特定应用程序的URL.
I have already tried mapping the URL for a particular app manually by adding the necessary frontend and backend configuration in the haproxy.conf.
frontend http-in
mode http
bind 206.189.22.155:80
acl path-page-designer path_beg -i /designer-api/
use_backend page-designer-backend if path-page-designer
backend page-designer-backend
mode http
option httplog
option forwardfor
server appserver1 206.189.22.155:30000
此配置工作正常,但我不想手动配置它,而是想通过命令行脚本自动映射发布管道中每个应用程序的URL.此命令行脚本应更新haproxy配置以自动重新映射URL每次运行发布管道时,该脚本也应该是通用脚本,其中应将应用程序特定的详细信息(例如port,/servicename等)作为参数从管道配置传递给脚本.我不想为每个应用程序创建单独的脚本.只是一个通用脚本,该脚本可用于所有管道,所以我该如何实现呢?请通过示例帮助我展示如何获取特定于应用程序的详细信息(例如port,/servicename等)并将其作为参数发送到命令行脚本的示例在发布管道中.
This config works perfectly fine.But instead of manually configuring this, I want to automatically map the url for each application in the release pipeline via a command line script.This command line script should update the haproxy configuration to automatically remap the URL every time a release pipeline is run.The script should also be a generic script with the application specific details(like port , /servicename etc) passed as parameter to the script from the pipeline configuration.i.e. i dont want to create separate script for each application. Just a single generic script, that’s used for all pipelines.So how can i achieve this?Plz help with examples showing how i can get application specific details(like port , /servicename etc) and send it as a parameter to the command line script in the release pipeline.
推荐答案
您可以将consul集成到haproxy中,请查看以下文章:
You can use the consul integration with haproxy, please review the following post:
https://learn.hashicorp.com/consul/integrations/haproxy-consul
我希望这会有所帮助.
这篇关于如何使用命令行脚本动态配置haproxy?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!