HAProxy antwortet mit derselben Anfrage manchmal mit NOSRV, während das Backend aktiv ist

HAProxy antwortet mit derselben Anfrage manchmal mit NOSRV, während das Backend aktiv ist

Ich mache die gleiche Anfrage (POST /user/oauth) an haproxy, aber manchmal bekomme ich 503, das Senden von Anfragen direkt an das Backend funktioniert immer

hier sind die Protokolle:

  1. local_server~ app/s2 0/0/0/100/100 200 813 - - --VN 1/1/0/0/0 0/0 "POST /Benutzer/oauth HTTP/1.1"
  2. local_server~ app/s1 0/0/1/107/108 200 820 - - --NI 1/1/0/0/0 0/0 "POST /Benutzer/oauth HTTP/1.1"
  3. local_server~ app/NOSRV 0/-1/-1/-1/0 503 216 - - SCNN 1/1/0/0/0 0/0 "POST /Benutzer/oauth HTTP/1.1"
  4. local_server~ app/NOSRV 0/-1/-1/-1/0 503 216 - - SCNN 1/1/0/0/0 0/0 "POST /Benutzer/oauth HTTP/1.1"
  5. local_server~ app/s2 0/0/1/106/107 200 831 - - --NI 2/2/0/0/0 0/0 "POST /Benutzer/oauth HTTP/1.1"
  6. local_server~ app/s1 0/0/1/3/6206 101 337 - - --NI 3/3/1/1/0 0/0 "GET / HTTP/1.1"
  7. local_server~ app/s1 0/0/1/83/84 200 258 - - --VN 2/2/0/0/0 0/0 "POST /Transaktion/Transaktion abschließen HTTP/1.1"
  8. local_server~ app/NOSRV 0/-1/-1/-1/0 503 216 - - SCNN 1/1/0/0/0 0/0 "POST /Benutzer/oauth HTTP/1.1"
  9. local_server~ app/s2 0/0/1/107/108 200 831 - - --NI 1/1/0/0/0 0/0 "POST /Benutzer/oauth HTTP/1.1"

wie Sie sehen, geht der POST /user/oauth manchmal zu s1, manchmal zu s2 und manchmal zu NOSRV.

manchmal ist es 10 Mal hintereinander erfolgreich und manchmal ist es 10 Mal hintereinander fehlgeschlagen.

hier ist meine Konfiguration:

defaults
log     global
mode    http
option  httplog
option  dontlognull
timeout connect 10000
timeout client  50000
timeout server  50000
retries 3
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http

frontend local_server
bind *:8080 ssl crt /etc/letsencrypt/live/xxx/sslcert.pem
mode http
default_backend app

backend app
balance roundrobin
cookie SERVERID insert indirect nocache
http-send-name-header Host
server s1 172.26.13.134:3000 check cookie s1
server s2 172.26.13.134:3000 check cookie s2
http-request add-header X-Server %b

Bearbeiten:

Ich habe die Anfrage auf einen Quick-Python-Server umgeleitet, der auf einem lokalen Host läuft, aber das Problem besteht immer noch. Also habe ich die Konfigurationsdatei von Haproxy so bearbeitet, dass nur Server s1 127.0.0.1:8086 Cookie s1 überprüft.

und führen Sie das Python-Skript aus: python3 -m http.server 8086 --bind 127.0.0.1&

als ich vom Postboten aus zuschlug, hatte ich eher 3 Erfolge hintereinander als 503.

Antwort1

Ich glaube, das Problem liegt an der Version. Ich habe irgendwo gelesen, dass Version 1.9 besser funktioniert als 2.* Ich habe den Quellcode heruntergeladen und mit den folgenden Optionen kompiliert: make TARGET=linux-glibc USE_PCRE2=1 USE_PCRE2_JIT=1 USE_OPENSSL=1 USE_ZLIB=1 USE_REGPARAM=1 USE_SYSTEMD=1 USE_THREAD=1

wie Sie sehen, habe ich die Option „lua5“ absichtlich weggelassen. Sie ist der einzige Unterschied zu der Option, die Sie von „apt-get install“ erhalten.

das resultierende Binärsystem funktioniert sehr gut und ohne Probleme

verwandte Informationen