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

    Unable to configure haproxy. Need help please

    Scheduled Pinned Locked Moved pfSense Packages
    6 Posts 2 Posters 2.8k 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.
    • A
      apex
      last edited by

      I have one public ip and two servers behind pfsense. I am trying to use haproxy as reverse proxy for those servers.

      /var/etc/haproxy.cfg file contents:

      global
      maxconn 200
      stats socket /tmp/haproxy.socket level admin
      uid 80
      gid 80
      nbproc 1
      chroot /tmp/haproxy_chroot
      daemon

      listen HAProxyLocalStats
      bind 127.0.0.1:2200 name localstats
      mode http
      stats enable
      stats admin if TRUE
      stats uri /haproxy_stats.php?haproxystats=1
      timeout client 5000
      timeout connect 5000
      timeout server 5000

      frontend frontend
      bind 125.20.185.43:80 name 125.20.185.43:80 
      mode http
      log global
      option http-keep-alive
      option forwardfor
      acl https ssl_fc
      reqadd X-Forwarded-Proto:\ http if !https
      reqadd X-Forwarded-Proto:\ https if https
      maxconn 200
      timeout client 30000
      acl aclusr_host_starts_with_domain1.com hdr_beg(host) -i domain1.com
      acl aclusr_host_starts_with_domain2.com hdr_beg(host) -i domain2.com
      use_backend servers_http_ipvANY if aclusr_host_starts_domain1.com
      use_backend servers_http_ipvANY if aclusr_path_starts_with_domain2.com

      backend servers_http_ipvANY
      mode http
      stats enable
      stats uri /haproxy?stats
      stats realm haproxystats
      stats auth admin:**************
      stats refresh 30m
      timeout connect 30000
      timeout server 30000
      retries 3
      option httpchk OPTIONS /
      server server1 192.168.1.2:80 check inter 1000  weight 1
      server server2 192.168.1.5:80 check inter 1000  weight 1

      What i'm doing wrong?

      Can someone help me to configure haproxy correctly?

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

        It is required to have 2 backends, and also configure a second 'shared' frontend for the domain2 which will point to backend2 when its acl matches.

        1 Reply Last reply Reply Quote 0
        • A
          apex
          last edited by

          Im getting error

          Multiple primary frontends with IP:Port "125.20.185.43:80", use Shared-Frontends instead.

          1 Reply Last reply Reply Quote 0
          • A
            apex
            last edited by

            How to create shared frontend's?

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

              Create 1 primary frontend like you did.
              Then add a second frontend and check the 'shared' checkbox.

              1 Reply Last reply Reply Quote 0
              • A
                apex
                last edited by

                Thank you,

                My mistake was that i used clone option on first frontend, then you can't see shared option.  :'(

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