Unable to configure haproxy. Need help please
-
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
daemonlisten 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 5000frontend 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.combackend 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 1What i'm doing wrong?
Can someone help me to configure haproxy correctly?
-
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.
-
Im getting error
Multiple primary frontends with IP:Port "125.20.185.43:80", use Shared-Frontends instead.
-
How to create shared frontend's?
-
Create 1 primary frontend like you did.
Then add a second frontend and check the 'shared' checkbox. -
Thank you,
My mistake was that i used clone option on first frontend, then you can't see shared option. :'(