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

    pfSense mit HAproxy funktioniert nur kurze Zeit

    Scheduled Pinned Locked Moved Deutsch
    2 Posts 2 Posters 370 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.
    • I
      ips-ad
      last edited by

      Hallo zusammen,

      ich "erforsche" gerade die pfSense mit HAproxy und bin dabei auf ein Phänomen gestoßen, bei dem ich nicht weiterkomme und mich über Hinweise/Ideen freuen würde :-)

      Ich habe eine Umgebung aufgesetzt, bei der mehrere unterschiedliche http-Server als Docker-Container laufen und (noch ohne Load Balancing) mit SSL Offloading auf unterschiedlichen Ports extern erreichbar sind. Das funktioniert, aber es funktioniert immer nur ein paar Minuten lang, bis es dann ein 504 Gateway Time-out gibt (obwohl die Checks in der HAProxy-Statistik ok sind). Öffne ich ein neues Inkognito-Browserfenster, dann klappt es wieder ein Weilchen, bis das Spiel von vorne losgeht.

      Hier der Vergleich von HAProxy-Logs - oben klappt es, unten nicht:

      [2020-10-11T11:16:14.857080] Incoming log entry; line='<134>Oct 11 13:16:14 haproxy[78394]: 116.202.xxx:54896 [11/Oct/2020:13:15:14.839] frontend-host~ backend-host_ipvANY/172.20.x.2 0/0/1/-1/60018 504 194 - - sH-- 1/1/0/0/0 0/0 "GET /swagger/index.html HTTP/1.1"\x0a'
      
      
      [2020-10-11T11:17:05.183193] Incoming log entry; line='<134>Oct 11 13:17:05 haproxy[78394]: 116.202.xxx:55512 [11/Oct/2020:13:17:05.173] frontend-host~ backend-host_ipvANY/172.20.x.2 0/0/1/10/11 200 5630 - - ---- 2/2/1/2/0 0/0 "GET /swagger/index.html HTTP/1.1"\x0a'
      

      Zum Setup:

      • pfSense bei Hetzner in der Cloud mit zusätzlicher Floating IP auf dem WAN-Interface (eingerichtet als IP Alias) - die Floating IP soll dabei für HAproxy genutzt werden
      • ein Docker-Server mit diversen Webservern (ONLYOFFICE und eine ASP.NET Core-App mit Front-/Backend) auf unterschiedlichen Ports im LAN
      • kaum Anpassungen an der pfSense bis auf die nötigen ACLs für HAProxy und ein IPsec-S2S-VPN

      Vielen Dank für jegliche Hinweise!!

      Hier noch die generierte HAProxy-Config:

      # Automaticaly generated, dont edit manually.
      # Generated on: 2020-10-11 18:11
      global
      	maxconn			1000
      	log			172.20.x.2:514	local0	debug
      	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
      	server-state-file /tmp/haproxy_server_state
      
      listen HAProxyLocalStats
      	bind 127.0.0.1:2200 name localstats
      	mode http
      	stats enable
      	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 oo01front
      	bind			78.46.xxx:9101 name 78.46.xxx:9101   ssl crt-list /var/etc/haproxy/oo01front.crt_list  
      	mode			http
      	log			global
      	option			http-keep-alive
      	option			forwardfor
      	acl https ssl_fc
      	http-request set-header		X-Forwarded-Proto http if !https
      	http-request set-header		X-Forwarded-Proto https if https
      	timeout client		30000
      	acl			aclcrt_oo01front	var(txn.txnhost) -m reg -i ^bla\.blabla\.com(:([0-9]){1,5})?$
      	http-request set-var(txn.txnhost) hdr(host)
      	use_backend oo01_ipvANY  if   aclcrt_oo01front
      
      frontend ipswebback01-front
      	bind			78.46.xxx:4443 name 78.46.xxx:4443   ssl crt-list /var/etc/haproxy/ipswebback01-front.crt_list  
      	mode			http
      	log			global
      	option			http-keep-alive
      	option			forwardfor
      	acl https ssl_fc
      	http-request set-header		X-Forwarded-Proto http if !https
      	http-request set-header		X-Forwarded-Proto https if https
      	timeout client		30000
      	acl			aclcrt_ipswebback01-front	var(txn.txnhost) -m reg -i ^bla\.blabla\.com(:([0-9]){1,5})?$
      	http-request set-var(txn.txnhost) hdr(host)
      	use_backend ipswebback01_ipvANY  if   aclcrt_ipswebback01-front
      
      frontend ipswebfront01-front
      	bind			78.46.xxx:443 name 78.46.xxx:443   ssl crt-list /var/etc/haproxy/ipswebfront01-front.crt_list  
      	mode			http
      	log			global
      	option			http-keep-alive
      	option			forwardfor
      	acl https ssl_fc
      	http-request set-header		X-Forwarded-Proto http if !https
      	http-request set-header		X-Forwarded-Proto https if https
      	timeout client		30000
      	acl			aclcrt_ipswebfront01-front	var(txn.txnhost) -m reg -i ^bla\.blabla\.com(:([0-9]){1,5})?$
      	http-request set-var(txn.txnhost) hdr(host)
      	use_backend ipswebfront01_ipvANY  if   aclcrt_ipswebfront01-front
      
      frontend http-to-https
      	bind			78.46.xxx:80 name 78.46.xxx:80   
      	mode			http
      	log			global
      	option			http-keep-alive
      	timeout client		30000
      	http-request redirect scheme https 
      
      backend oo01_ipvANY
      	mode			http
      	id			100
      	log			global
      	timeout connect		30000
      	timeout server		100000
      	retries			3
      	option			httpchk GET / 
      	server			dockeroo01 172.20.x.2:9101 id 101 check inter 1000  
      
      backend ipswebback01_ipvANY
      	mode			http
      	id			102
      	log			global
      	timeout connect		30000
      	timeout server		100000
      	retries			3
      	option			httpchk GET / 
      	server			ipswebback01 172.20.x.2:8081 id 101 check inter 1000  
      
      backend ipswebfront01_ipvANY
      	mode			http
      	id			103
      	log			global
      	timeout connect		30000
      	timeout server		100000
      	retries			3
      	option			httpchk GET / 
      	server			ipswebfront01 172.20.x.2:8080 id 101 check inter 1000
      
      1 Reply Last reply Reply Quote 0
      • JeGrJ
        JeGr LAYER 8 Moderator
        last edited by

        @ips-ad said in pfSense mit HAproxy funktioniert nur kurze Zeit:

        bis es dann ein 504 Gateway Time-out gibt (obwohl die Checks in der HAProxy-Statistik ok sind). Öffne ich ein neues Inkognito-Browserfenster, dann klappt es wieder ein Weilchen, bis das Spiel von vorne losgeht.

        Sind die wirklich durchgehend OK? 504 ist eigentlich klarer Fall, dass das Backend nicht erreichbar ist/war. Hast du mal testweise den Backend Check einfach disabled (und damit quasi immer OK angenommen)? Tritt es dann auch auf?

        Don't forget to upvote 👍 those who kindly offered their time and brainpower to help you!

        If you're interested, I'm available to discuss details of German-speaking paid support (for companies) if needed.

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