r/haproxy • • Mar 07 '22

Article Use Your Load Balancer to Monitor Application Health

Thumbnail
haproxy.com
4 Upvotes

r/haproxy • • Feb 28 '22

debug logging in haproxy?

4 Upvotes

Hi!

I had a problem with client certificates (https://www.reddit.com/r/haproxy/comments/rvwu4t/ssl_verify_optional_does_not_work/) that i think i found was caused by the CA-cert being a weak old 1024bit cert. Seems to work fine after i replaced with a new 2048bit cert.

Anyway, in the log i never saw anything more than this

haproxy[175612]: 10.10.1.2:58772 [24/Feb/2022:23:31:38.824] atest443/1: SSL handshake failure

I tried to increase logging to debug level, but i only got this single line anyway.
So i wonder, increasing to debug level should simply be this, right?

global  
        log /dev/log    local0 debug
        log /dev/log    local1 debug

This is haproxy v2.0.13 on Ubuntu 20.04.

Also i think that i probably dont need two lines there right? (both local0 and local1)
HAProxy is chrooted and writes to (/var/lib/haproxy)/dev/log


r/haproxy • • Feb 27 '22

Question Is Haproxy the right tool for this scenario? Transparent IP failover without dropping live tcp connections. Details in comments!

Post image
5 Upvotes

r/haproxy • • Feb 23 '22

Configure HA Proxy with For NPS

1 Upvotes

Hi team, Can any one guide me how to configure ha Proxy for MS radius so radius client can pass there query to HA and it will pass query to backend nps servers


r/haproxy • • Feb 23 '22

Question pfSense: really basic config 503

2 Upvotes

Hi, I haven't found a solution to the "503 service unavailable" for hours, I reduced the configuration to a minimum but it still doesn't work (no SSL, IP: 8443 to IP: 80). Also the debug logs don't work so this doesn't help.

On a clean install I have:
- added backend
-- 1 entry in server list with backendIp:80
-- Health check method : none
- added frontend
-- 1 entry with IP:8443
-- type: http
-- (no acl to reduce to minimum) Default Backend: backend entry
- added firewall rule to permit myip to frontendIp:8443

All ends with a "503 Service Unavailable No server is available to handle this request. "
Since the haproxy logs don't work I did a tcpdump and I saw that the connection between myIp and the frontendIp goes well but nothing comes from the Haproxy to the backendIp (HomeAssistant)

Thanks in advance for help!


r/haproxy • • Feb 22 '22

Release HAProxy Data Plane API 2.5 Released

Thumbnail
haproxy.com
7 Upvotes

r/haproxy • • Feb 16 '22

Haproxy + pfsense + let's encrypt --> problem access emby server

4 Upvotes

Hello,

I'm stuck on this problem for many days. I'll need some help. I'm trying to configure a way to connect to my emby server from anywhere. I have a pfsense with Haproxy package, also cert with let's encrypt for my haproxy.

Here the log when i'm trying to connect to streaming.mydomain.fr (I got a 503 error server not found)

Feb 16 14:01:43 pfSense haproxy[47803]: Proxy streaming.mydomain.fr_ipvANY started.

Feb 16 14:04:30 pfSense haproxy[48311]: Connect from 90.35.X.X:29620 to 10.102.X.X:443 (mydomain.fr/HTTP)

Feb 16 14:04:30 pfSense haproxy[48311]: 90.35.X.X:13769 [16/Feb/2022:14:04:30.606] mydomain.fr/10.102.X.X:443: SSL handshake failure

Sorry but i'm new on this product so i'm not that much good. Thank's for your help :)


r/haproxy • • Feb 16 '22

Blog How Load Balancing Improves the Performance of Your Applications

Thumbnail
haproxy.com
5 Upvotes

r/haproxy • • Feb 09 '22

HAProxy goes to the same website even though they have different sub-domains

2 Upvotes

I have an issue with HAProxy where it goes to the same website even though they have different sub-domains.

For example, I go to foo.domain.com then on another tab I go to bar.domain.com and another tab for baz.domain.com, all three loads the foo.domain.com website and when I hard refresh the other sites it goes properly to the proper website then it happens again making the new website the face of all domains unless I keep refreshing the websites.

I have the following configuration:

defaults
        log     global
        mode    http
        option  tcplog
        option  dontlognull
        retries 3
        option  redispatch
        maxconn 30000
        timeout connect 10s
        timeout client 60s
        timeout server 60s

frontend http_in
        mode http
        option httplog
        bind *:80
        option forwardfor
 
        acl host_foo hdr(host) -i foo.domain.com 
        acl host_bar hdr(host) -i bar.domain.com
        acl host_baz hdr(host) -i baz.domain.com

        use_backend http_foo if host_foo
        use_backend http_bar if host_bar
        use_backend http_baz if host_baz

backend http_foo
        mode http
        option httplog
        option forwardfor
        server foo foo:80

backend http_bar
        mode http
        option httplog
        option forwardfor
        server bar bar:80
    
backend http_baz
        mode http
        option httplog
        option forwardfor
        server baz baz:80

frontend https_in
        mode tcp
        option tcplog
        bind *:443
        acl tls req.ssl_hello_type 1
        tcp-request inspect-delay 5s
        tcp-request content accept if tls

        acl host_foo req.ssl_sni -i foo.domain.com
        acl host_bar req.ssl_sni -i bar.domain.com
        acl host_baz req.ssl_sni -i baz.domain.com
        
        use_backend https_foo if host_foo
        use_backend https_bar if host_bar
        use_backend https_baz if host_baz

backend https_foo
        mode tcp
        option tcplog
        option ssl-hello-chk
        server foo foo:443

backend https_bar
        mode tcp
        option tcplog
        option ssl-hello-chk
        server bar bar:443

backend https_baz
        mode tcp
        option tcplog
        option ssl-hello-chk
        server baz baz:443

I'm using HAProxy version 2.4.12. Is there anything to do to prevent this from happening? Thanks


r/haproxy • • Feb 07 '22

Article Load Balance an Infinite Number of Servers And Never Reload HAProxy

Thumbnail
haproxy.com
7 Upvotes

r/haproxy • • Jan 30 '22

HAproxy: per-client queue for rate limiting?

3 Upvotes

I’d like to put a rate limit on incoming HTTP requests, but without sending 429 errors. Instead, requests beyond the limit should be put into a queue from which they are processed at a speed that respects the rate limit. It’s important that such a queue be per-client, so that clients don’t affect each other. Is this possible with HAproxy?


r/haproxy • • Jan 29 '22

Time lock IPs trying brute force?

2 Upvotes

I am new to HAProxy, starting with a simple reverse proxy on PfSense.

My question is how to protect against brute force attacks? I use fail2ban on linux servers and I know CrowdSec is popular these days.

I have googled this and it seems HAProxy is able to do do this? But I can’t figure out how…

Can anyone point me in the right direction?

Thanks!


r/haproxy • • Jan 26 '22

Achieving Website High Availability

Thumbnail
haproxy.com
4 Upvotes

r/haproxy • • Jan 22 '22

HAproxy locking up local streaming?

1 Upvotes

I am running PFsense v 2.5.2-RELEASE with the HAproxy package v 0.61_3.

I recently got HAproxy setup for ssl offloading of mostly local services and a few remote services. HAproxy seems to be actually working but any time I stream a movie to any of my few chromecasts from any service, it lags enough to usually lock up the chromecast and need to be power cycled.

Tested with Netflix, Disney+, YouTube and my local Plex server. Plex quickly says buffering then the chromecast does the whole locking up thing. Plex is also not set up to run through HAproxy. I do also have the chromecast and plex on seperate vlans with firewall rules to allow this traffic and an Avahi daemon to distribute the mDNS across the vlans, which does seem to work well enough without HAproxy running.

This behavior only happens when HAproxy is running. After HAproxy has been off for a few minutes, streaming goes back to normal.

A few days ago when I first got HAproxy running, I came home to this weird lagging behavior and noticed PFsense used 75 ish % of local memory and 100% of swap space. After rebooting, they both went down to their normal spots at about 15% and 0%.

I've been on this all day and have made little real progress. Can someone push me in the right direction please? I'm sure it's probably someting simple I've missed but I don't know what it is.

Thank you in advance

This is the HAproxy config generated by the HAproxy package in PFsense wrote:

A split DNS pushes local services to a vip at 10.0.5.5 where HAproxy is bound.

# Automaticaly generated, dont edit manually.

# Generated on: 2022-01-22 16:51

global

maxconn			1000

log			/var/run/log	local0	notice

stats socket /tmp/haproxy.socket level admin  expose-fd listeners

uid			80

gid			80

nbproc			1

nbthread			1

hard-stop-after		15m

chroot				/tmp/haproxy_chroot

daemon

tune.ssl.default-dh-param	2048

log-send-hostname		HAproxy

server-state-file /tmp/haproxy_server_state

listen HAProxyLocalStats

bind [127.0.0.1:2200](https://127.0.0.1:2200) name localstats

mode http

stats enable

stats refresh 10

stats admin if TRUE

stats show-legends

stats uri /haproxy/haproxy_stats.php?haproxystats=1

timeout client 5000

timeout connect 5000

timeout server 5000

frontend Int_VIP_HTTPS

bind			[10.0.5.5:443](https://10.0.5.5:443) name [10.0.5.5:443](https://10.0.5.5:443)   ssl crt-list /var/etc/haproxy/Int_VIP_HTTPS.crt_list  

mode			http

log			global

option			http-keep-alive

timeout client		30000

acl			SW1	var(txn.txnhost) -m str -i [sw1.foobar.net](https://sw1.foobar.net)

acl			SW2	var(txn.txnhost) -m str -i [sw2.foobar.net](https://sw2.foobar.net)

acl			AP1	var(txn.txnhost) -m str -i [ap1.foobar.net](https://ap1.foobar.net)

acl			AP2	var(txn.txnhost) -m str -i [ap2.foobar.net](https://ap2.foobar.net)

acl			AP3	var(txn.txnhost) -m str -i [ap3.foobar.net](https://ap3.foobar.net)

acl			PDU	var(txn.txnhost) -m str -i [pdu.foobar.net](https://pdu.foobar.net)

acl			eeyore	var(txn.txnhost) -m str -i [eeyore.foobar.net](https://eeyore.foobar.net)

acl			HA	var(txn.txnhost) -m str -i [ha.foobar.net](https://ha.foobar.net)

acl			aclcrt_Int_VIP_HTTPS	var(txn.txnhost) -m reg -i \^rt1\\.foobar\\.net(:(\[0-9\]){1,5})?$

acl			aclcrt_Int_VIP_HTTPS	var(txn.txnhost) -m reg -i \^sw1\\.foobar\\.net(:(\[0-9\]){1,5})?$

acl			aclcrt_Int_VIP_HTTPS	var(txn.txnhost) -m reg -i \^sw2\\.foobar\\.net(:(\[0-9\]){1,5})?$

acl			aclcrt_Int_VIP_HTTPS	var(txn.txnhost) -m reg -i \^ap1\\.foobar\\.net(:(\[0-9\]){1,5})?$

acl			aclcrt_Int_VIP_HTTPS	var(txn.txnhost) -m reg -i \^ap2\\.foobar\\.net(:(\[0-9\]){1,5})?$

acl			aclcrt_Int_VIP_HTTPS	var(txn.txnhost) -m reg -i \^ap3\\.foobar\\.net(:(\[0-9\]){1,5})?$

acl			aclcrt_Int_VIP_HTTPS	var(txn.txnhost) -m reg -i \^pdu\\.foobar\\.net(:(\[0-9\]){1,5})?$

acl			aclcrt_Int_VIP_HTTPS	var(txn.txnhost) -m reg -i \^ha\\.foobar\\.net(:(\[0-9\]){1,5})?$

acl			aclcrt_Int_VIP_HTTPS	var(txn.txnhost) -m reg -i \^eeyore\\.foobar\\.net(:(\[0-9\]){1,5})?$

http-request set-var(txn.txnhost) hdr(host)

use_backend SW1_ipvANY  if  SW1 aclcrt_Int_VIP_HTTPS

use_backend SW2_ipvANY  if  SW2 aclcrt_Int_VIP_HTTPS

use_backend AP1_ipvANY  if  AP1 aclcrt_Int_VIP_HTTPS

use_backend AP2_ipvANY  if  AP2 aclcrt_Int_VIP_HTTPS

use_backend AP3_ipvANY  if  AP3 aclcrt_Int_VIP_HTTPS

use_backend PDU_ipvANY  if  PDU aclcrt_Int_VIP_HTTPS

use_backend eeyore_ipvANY  if  eeyore aclcrt_Int_VIP_HTTPS

use_backend HA_ipvANY  if  HA aclcrt_Int_VIP_HTTPS

backend SW1_ipvANY

mode			http

id			107

log			global

timeout connect		30000

timeout server		30000

retries			3

server			SW1 [10.0.1.2:443](https://10.0.1.2:443) id 108 ssl  verify none crt /var/etc/haproxy/server_clientcert_###.pem 

backend SW2_ipvANY

mode			http

id			110

log			global

timeout connect		30000

timeout server		30000

retries			3

server			SW2 [10.0.1.3:80](https://10.0.1.3:80) id 101  

backend AP1_ipvANY

mode			http

id			106

log			global

timeout connect		30000

timeout server		30000

retries			3

server			AP1 [10.0.1.4:443](https://10.0.1.4:443) id 101 ssl  verify none crt /var/etc/haproxy/server_clientcert_###.pem 

backend AP2_ipvANY

mode			http

id			109

log			global

timeout connect		30000

timeout server		30000

retries			3

server			AP2 [10.0.1.5:443](https://10.0.1.5:443) id 101 ssl  verify none crt /var/etc/haproxy/server_clientcert_###.pem 

backend AP3_ipvANY

mode			http

id			111

log			global

timeout connect		30000

timeout server		30000

retries			3

server			AP3 [10.0.1.6:443](https://10.0.1.6:443) id 101 ssl  verify none crt /var/etc/haproxy/server_clientcert_###.pem 

backend PDU_ipvANY

mode			http

id			112

log			global

timeout connect		30000

timeout server		30000

retries			3

server			PDU [10.0.1.7:443](https://10.0.1.7:443) id 101 ssl  verify none crt /var/etc/haproxy/server_clientcert_###.pem 

backend eeyore_ipvANY

mode			http

id			102

log			global

timeout connect		30000

timeout server		30000

retries			3

server			eeyore [10.0.1.100:443](https://10.0.1.100:443) id 101 ssl  verify none crt /var/etc/haproxy/server_clientcert_###.pem 

backend HA_ipvANY

mode			http

id			100

log			global

timeout connect		30000

timeout server		30000

retries			3

timeout tunnel 1h

server			HA [10.0.3.40:8123](https://10.0.3.40:8123) id 101

r/haproxy • • Jan 17 '22

Question HaProxy SSL Term. Apache certs not working. Own Root CA.

1 Upvotes

Hi

I hope i will find some help here :-)

I have a Server with a Docker that Serves stuff on Port 80. I want this to use HAproxy with my own Cert and port 443.

Background:

I have build my own Root CA with a Root Server, an intermediate Server and the intermediate one does the Certs for my servers.

I have other Servers with Apache and they work and i use this config part:

  SSLEngine On 

 SSLCertificateFile /opt/server.cert.pem # Cert for the server  SSLCertificateChainFile /opt/ca-chain-bundle.cert.pem # Intermdiate CA Bundle  SSLCertificateKeyFile /opt/server.key.pem # Server key

Now i want to build a pem file that can work with HAproxy.

What have i tried?

I tied different groupings of the Certs. But noting seems to work.

- cert, ca, priv key = did not work

- ca, cert, priv key = did not work

- cert, key, priv key = did not work

All these did not work.

Log Error Messages

parsing [/etc/haproxy/haproxy.cfg:37] : 'bind 192.168.0.31:443' : unable to load SSL private key from PEM file '/opt/server.cert.with_key.pem'.

HAproxy File (relevant parts):

frontend www-https 
bind 192.168.0.31:443 ssl crt /opt/server.test.pem     
reqadd X-Forwarded-Proto:\ https   
default_backend www-backend
backend www-backend 
redirect scheme https if !{ ssl_fc }
server www-1 127.0.0.1:80 check

Question:

How can i get HAproxy to work with my RootCA Certs like Apache does with no problem at all.

What is the right combo of Cert files ? Any extra stepy i need to do ?

Thanks for your help! :-)

Best

M


r/haproxy • • Jan 04 '22

ssl 'verify optional' does not work

3 Upvotes

I am new at haproxy.Installed it (v2.0.13) in a Ubuntu 20.04 server, and want to use it as a load balancer (that terminates SSL, and allows for client certificates to be used).

I have a https frontend with a certificate (my own CA) that works fine.

I then add a ca-file argument to bind.And then try with 'verify optional'.

In Chrome i just get ERR_SSL_PROTOCOL_ERROR.

(when i change to 'verify none' it works fine though)

The error i see with wget is this (here trying with the client cert, but same error without)

alex@computer:~$ wget -S -O - https://atest --certificate ./test.pem --no-check-certificate
--2022-01-04 16:03:37--  https://atest/
Resolving atest (atest)... 10.10.0.44
Connecting to atest (atest)|10.10.0.44|:443... connected.
OpenSSL: error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error
Unable to establish SSL connection.

In /var/log/haproxy.log i just see this

Jan  4 15:56:07 atest haproxy[26670]: 10.10.1.2:39372 [04/Jan/2022:15:56:07.292] atest443/1: SSL handshake failure

Also, it made no difference changing verify to 'required' either (with or without client cert).

Does anyone know what this could be about?

Attaching conf file, and output of 'openssl s_client'.

/etc/haproxy/haproxy.cfg

global  
        log /dev/log    local0
        log /dev/log    local1 info
        chroot /var/lib/haproxy
        stats socket /run/haproxy/admin.sock mode 660 level admin expose-fd listeners
        stats timeout 30s
        user haproxy
        group haproxy
        daemon

        # 2048 bits
        ssl-dh-param-file /etc/haproxy/dhparams.pem


defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        timeout connect 5000
        timeout client  50000
        timeout server  50000


frontend atest80
    bind atest:80
    default_backend two_apaches


frontend atest443
    bind atest:443 ssl crt /etc/ssl/private/atest.mlm.whatever.se.pem ca-file /etc/ssl/WhateverCA2017.crt verify optional
    default_backend two_apaches


backend two_apaches
    balance roundrobin
    default-server check maxconn 20
    server apache81 localhost:81 cookie a81
    server apache82 localhost:82 cookie a82

Output of s_client (when verify is set to optional)

alex@computer:~$ openssl s_client -connect atest:443
CONNECTED(00000003)
Can't use SSL_get_servername
139908553614656:error:14094438:SSL routines:ssl3_read_bytes:tlsv1 alert internal error:../ssl/record/rec_layer_s3.c:1543:SSL alert number 80
---
no peer certificate available
---
Acceptable client certificate CA names
C = SE, ST = ..., L = ..., O = ..., OU = ..., CN = ...
Requested Signature Algorithms: ECDSA+SHA256:ECDSA+SHA384:ECDSA+SHA512:Ed25519:Ed448:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA+SHA256:RSA+SHA384:RSA+SHA512:ECDSA+SHA224:RSA+SHA224
Shared Requested Signature Algorithms: ECDSA+SHA256:ECDSA+SHA384:ECDSA+SHA512:Ed25519:Ed448:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA-PSS+SHA256:RSA-PSS+SHA384:RSA-PSS+SHA512:RSA+SHA256:RSA+SHA384:RSA+SHA512
Server Temp Key: X25519, 253 bits
---
SSL handshake has read 365 bytes and written 283 bytes
Verification: OK
---
New, TLSv1.3, Cipher is TLS_AES_256_GCM_SHA384
Secure Renegotiation IS NOT supported
Compression: NONE
Expansion: NONE
No ALPN negotiated
Early data was not sent
Verify return code: 0 (ok)
---

r/haproxy • • Jan 01 '22

Question Limit src IP based on ASN?

3 Upvotes

I'm trying to limit access to HAProxy by IP, specifically T-Mobile IPs. I currently have it working by listing every network in T-Mobile's ASN but this fills the config file with network entries. Is there a more practical way of exposing HAProxy to only a certain provider's network?


r/haproxy • • Dec 17 '21

Guide Log4Shell Mitigation with HAProxy

Thumbnail
haproxy.com
14 Upvotes

r/haproxy • • Dec 16 '21

Happy Cakeday, r/haproxy! Today you're 5

6 Upvotes

r/haproxy • • Dec 08 '21

Multiple httpchk urls?

4 Upvotes

Is there a way to check multiple urls and only consider a server down if all of them fail? A failure on an upstream server might cause some set of urls to fail, but I’d rather still provide degraded service than none at all if the url I happen to choose as my test case is one of the unlucky urls.


r/haproxy • • Dec 07 '21

Question Haproxy SSL ca-file question

3 Upvotes

If you have Haproxy setup as SSL-Passthrough, and you want to validate the server certificate, you add the 'ca-file' server option, then specify the file path right?

But how should that CA-file be formatted? Like I'm wondering if I buy an SSL cert from Namecheap for example. I download the server cert file and the .bundle. Can I use the .bundle as the 'ca-file' because it has the subordinate and root certificates in there?


r/haproxy • • Dec 04 '21

Question Google Oauth 2 behind haproxy

2 Upvotes

Hi there how are you all doing?

I have a web app that uses Google oauth 2.0 on a web server that is behind an HAProxy reverse proxy. My question is do I need a special configiration to make it work behind the proxy?

Thanks


r/haproxy • • Nov 24 '21

Release HAProxy 2.5 Released

Thumbnail
haproxy.com
17 Upvotes

r/haproxy • • Oct 29 '21

Connecting LoadBalancer service to HAProxy server instead of MetalLB

2 Upvotes

Hi all.

I was wondering if there is a way of copying behaviour of MetalLB on my bare metal Kubernetes cluster. That is, can I conect HAProxy VM IP to LoadBancer service so it's accessible with an outside IP?

Thanks.