Netgate Discussion Forum
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Search
    • Register
    • Login

    HAProxy support for server-template backends (Consul, etc)

    Scheduled Pinned Locked Moved Cache/Proxy
    3 Posts 2 Posters 1.3k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • Y
      yammering
      last edited by

      I am migrating an existing HAProxy install over to pfSense and enjoying the convenient configuration UI. But I could not find a way to add server-template backends. My configuration was like this (from https://learn.hashicorp.com/consul/integrations/haproxy-consul#create-the-haproxy-configuration)

      frontend http_front
         bind *:80
         default_backend http_back
      
      backend http_back
          balance roundrobin
          server-template mywebapp 10 _web._tcp.service.consul resolvers consul    resolve-opts allow-dup-ip resolve-prefer ipv4 check
      
      resolvers consul
        nameserver consul 127.0.0.1:8600
        accepted_payload_size 8192
        hold valid 5s
      

      To replicate this I need some way to add a new "resolvers" block. The existing Advanced field forces configuration into the "global" section which is inadequate. Does anyone know how to add arbitrary configuration? Or if the HAProxy module's config UI code is open source and could be patched to add this?

      P 1 Reply Last reply Reply Quote 0
      • P
        PiBa @yammering
        last edited by

        @yammering
        You can add the nameserver section resolvers consul to the advanced settings on the settings tab.
        And add the server option 'resolvers consul' reference to the 'Per server pass thru'.. The servers do have a field to fill in a 'template count', that way it will create the server-template option instead of a single server Though for that to work there 'must' be a globalresolver configured. Ending up with 2 resolvers on the server line.. so im not sure if it will use the proper 2nd one then..
        Other option would be to not define a server in the backend, but write the template line manually in advanced section.. Though the use of a webgui looses its advantages that way.. and usage of certificates can become rather difficult..

        1 Reply Last reply Reply Quote 1
        • Y
          yammering
          last edited by

          That worked great. I didn't realize you could put the resolvers under global and still have it work.

          1 Reply Last reply Reply Quote 0
          • First post
            Last post
          Copyright 2025 Rubicon Communications LLC (Netgate). All rights reserved.