how to dynamically configure haproxy using a command line script?

穿精又带淫゛_ 提交于 2019-12-13 03:26:08

问题


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/.

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

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.


回答1:


You can use the consul integration with haproxy, please review the following post:

https://learn.hashicorp.com/consul/integrations/haproxy-consul

I hope this helps.



来源:https://stackoverflow.com/questions/57876180/how-to-dynamically-configure-haproxy-using-a-command-line-script

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!