Mijn situatie:
Internet komt via FRITZ!Box 7581 binnen op Ubiquity Edgerouter. Poorten 80 en 443 zijn geforward naar Debian VM op MS HyperV 2012. Op deze VM heb ik haproxy en nginx geinstalleerd om als reverse proxy (zonder loadbalancing) inkomende webrequests door te sturen naar een paar interne webservers. LAN netwerk is 192.168.100.0/24 en DMZ netwerk is 172.16.3.0/24. In dit DMZ netwerk zit de haproxy server en een webserver.
Na het starten van haproxy duurt het even voordat de websites zichtbaar zijn. Waarschijnlijk omdat haproxy even nodig heeft om op te starten, maar daar heb ik geen bewijs van. Zodra haproxy eenmaal draait zijn de websites te benaderen, maar na een aantal nieuwe sessies stopt haproxy ermee.
In de haproxy logs zie ik dan onder andere de volgende meldingen:
...... http web01/web01 0/0/5/-1/10006 504 194 - - sH-- 0/0/0/0/0 0/0......
en
.......http web01/web01 0/0/-1/-1/40008 503 212 - - cC-- 0/0/0/0/3 0/0......
en
....... http http/<NOSRV> -1/-1/-1/-1/0 503 212 - - SC-- 0/0/0/0/0 0/0.......
mijn haproxy.conf:
Dit is niet mijn productie config, maar een uitgeklede configuratie voor test. In tests heb ik nginx ook gestopt. (Nginx gebruik ik oa voor letsencrypt acme challenges en wat authenticaties voor bepaalde sites.)
Volgens de haproxy site:
sH The "timeout server" stroke before the server could return its
response headers. This is the most common anomaly, indicating too
long transactions, probably caused by server or database saturation.
The immediate workaround consists in increasing the "timeout server"
setting, but it is important to keep in mind that the user experience
will suffer from these long response times. The only long term
solution is to fix the application.
c the client-side timeout expired while waiting for the client to send or receive data.
C the proxy was waiting for the CONNECTION to establish on the
server. The server might at most have noticed a connection attempt.
SC The server or an equipment between it and haproxy explicitly refused
the TCP connection (the proxy received a TCP RST or an ICMP message
in return). Under some circumstances, it can also be the network
stack telling the proxy that the server is unreachable (eg: no route,
or no ARP response on local network). When this happens in HTTP mode,
the status code is likely a 502 or 503 here.
Als ik de websites rechtstreeks oproep, dus buiten haproxy om, werken die zonder problemen, dus het lijkt geen webserver probleem.
Ik heb het vermoeden dat er iets in het netwerk deel niet goed gaat, aangezien ssh sessies naar de haproxy server er soms ook uitgegooid worden. Enkele minuten later beginnen de websites en ssh het langzamerhand weer te doen, waarna de websites er meestal weer me kappen.
Ik dacht in eerste instantie dat ik tegen het maximum tcp connecties aan zat, dus die heb ik verhoogd en nog wat settings aangepast:
sysctl net.ipv4.ip_local_port_range="15000 61000"
sysctl net.ipv4.tcp_fin_timeout=30
sysctl net.ipv4.tcp_tw_recycle=1
sysctl net.ipv4.tcp_tw_reuse=1
sysctl net.core.somaxconn=1024
Dit lijkt niet te helpen. Ook als ik met tcpdump het netwerkverkeer bekijk, zie ik rare dingen:
- Soms komen er helemaal geen connecties binnen (in de edgerouter logs worden ze wel verstuurd)
- Soms komen er wel connecties binnen, maar zie ik niet dat haproxy er iets mee doet: niks te zien in logs.
Ik heb de timeout settings in de config al hoger en lager ingesteld.
Debian 9 is geinstalleerd met alleen de basis componenten (ssh server en standard system utils).
Iemand een idee wat hier aan de hand kan zijn? Mist het OS misschien wat webserver tuning oid?
Internet komt via FRITZ!Box 7581 binnen op Ubiquity Edgerouter. Poorten 80 en 443 zijn geforward naar Debian VM op MS HyperV 2012. Op deze VM heb ik haproxy en nginx geinstalleerd om als reverse proxy (zonder loadbalancing) inkomende webrequests door te sturen naar een paar interne webservers. LAN netwerk is 192.168.100.0/24 en DMZ netwerk is 172.16.3.0/24. In dit DMZ netwerk zit de haproxy server en een webserver.
Na het starten van haproxy duurt het even voordat de websites zichtbaar zijn. Waarschijnlijk omdat haproxy even nodig heeft om op te starten, maar daar heb ik geen bewijs van. Zodra haproxy eenmaal draait zijn de websites te benaderen, maar na een aantal nieuwe sessies stopt haproxy ermee.
In de haproxy logs zie ik dan onder andere de volgende meldingen:
...... http web01/web01 0/0/5/-1/10006 504 194 - - sH-- 0/0/0/0/0 0/0......
en
.......http web01/web01 0/0/-1/-1/40008 503 212 - - cC-- 0/0/0/0/3 0/0......
en
....... http http/<NOSRV> -1/-1/-1/-1/0 503 212 - - SC-- 0/0/0/0/0 0/0.......
mijn haproxy.conf:
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
| global log /dev/log local0 log /dev/log local1 notice daemon chroot /var/lib/haproxy user haproxy group haproxy defaults mode http log global timeout server 10s timeout client 10s timeout connect 10s option http-ignore-probes option http-server-close option forwardfor option contstats option socket-stats option prefer-last-server frontend http bind *:80 option httplog acl host_domein hdr(host) -i domein.nl use_backend web01 if host_domein backend web01 server web01 172.16.3.2:80 |
Dit is niet mijn productie config, maar een uitgeklede configuratie voor test. In tests heb ik nginx ook gestopt. (Nginx gebruik ik oa voor letsencrypt acme challenges en wat authenticaties voor bepaalde sites.)
Volgens de haproxy site:
sH The "timeout server" stroke before the server could return its
response headers. This is the most common anomaly, indicating too
long transactions, probably caused by server or database saturation.
The immediate workaround consists in increasing the "timeout server"
setting, but it is important to keep in mind that the user experience
will suffer from these long response times. The only long term
solution is to fix the application.
c the client-side timeout expired while waiting for the client to send or receive data.
C the proxy was waiting for the CONNECTION to establish on the
server. The server might at most have noticed a connection attempt.
SC The server or an equipment between it and haproxy explicitly refused
the TCP connection (the proxy received a TCP RST or an ICMP message
in return). Under some circumstances, it can also be the network
stack telling the proxy that the server is unreachable (eg: no route,
or no ARP response on local network). When this happens in HTTP mode,
the status code is likely a 502 or 503 here.
Als ik de websites rechtstreeks oproep, dus buiten haproxy om, werken die zonder problemen, dus het lijkt geen webserver probleem.
Ik heb het vermoeden dat er iets in het netwerk deel niet goed gaat, aangezien ssh sessies naar de haproxy server er soms ook uitgegooid worden. Enkele minuten later beginnen de websites en ssh het langzamerhand weer te doen, waarna de websites er meestal weer me kappen.
Ik dacht in eerste instantie dat ik tegen het maximum tcp connecties aan zat, dus die heb ik verhoogd en nog wat settings aangepast:
sysctl net.ipv4.ip_local_port_range="15000 61000"
sysctl net.ipv4.tcp_fin_timeout=30
sysctl net.ipv4.tcp_tw_recycle=1
sysctl net.ipv4.tcp_tw_reuse=1
sysctl net.core.somaxconn=1024
Dit lijkt niet te helpen. Ook als ik met tcpdump het netwerkverkeer bekijk, zie ik rare dingen:
- Soms komen er helemaal geen connecties binnen (in de edgerouter logs worden ze wel verstuurd)
- Soms komen er wel connecties binnen, maar zie ik niet dat haproxy er iets mee doet: niks te zien in logs.
Ik heb de timeout settings in de config al hoger en lager ingesteld.
Debian 9 is geinstalleerd met alleen de basis componenten (ssh server en standard system utils).
Iemand een idee wat hier aan de hand kan zijn? Mist het OS misschien wat webserver tuning oid?
Jij bent degene die me opfokt!
JA JIJ!!!