I want to start use haproxy inside pfsense but redirection is not working entirely.
My haproxy configuration file is this:
# Automaticaly generated, dont edit manually.
# Generated on: 2024-01-30 08:58
global
maxconn 1000
log /var/run/log local0 info
stats socket /tmp/haproxy.socket level admin expose-fd listeners
uid 80
gid 80
nbthread 1
hard-stop-after 15m
chroot /tmp/haproxy_chroot
daemon
tune.ssl.default-dh-param 2048
server-state-file /tmp/haproxy_server_state
frontend ha_frontend
bind 192.168.1.1:10000 name 192.168.1.1:10000 ssl crt-list /var/etc/haproxy/ha_frontend.crt_list
mode http
log global
option log-separate-errors
option httplog
option http-keep-alive
timeout client 30000
acl msggw_acl var(txn.txnpath) -m beg -i /api/asl/msggw
acl aclcrt_ha_frontend var(txn.txnhost) -m reg -i ^([^\.]*)\.myplace\.com(:([0-9]){1,5})?$
http-request set-var(txn.txnpath) path
http-request set-var(txn.txnhost) hdr(host)
use_backend msggw2_ipvANY if msggw_acl aclcrt_ha_frontend
use_backend nginx_new_ipvANY if aclcrt_ha_frontend
backend msggw2_ipvANY
mode http
id 102
log global
option log-health-checks
http-check send meth GET
timeout connect 30000
timeout server 30000
retries 3
load-server-state-from-file global
option httpchk
server msggw2 38.22.112.236:5151 id 103 ssl check-ssl check inter 1000 verify none
backend nginx_new_ipvANY
mode http
id 104
log global
option log-health-checks
http-check send meth GET
timeout connect 30000
timeout server 30000
retries 3
load-server-state-from-file global
option httpchk
server nginx_new 38.22.112.236:443 id 105 ssl check-ssl check inter 1000 verify none
When I use https://vm2.myplace.com:10000/ in browser, redirect is correct. I am redirected to server 38.22.112.236 , where on 443 port, nginx is running.
But when I use https://vm2.myplace.com:10000/api/asl/msggw , I want to be redirected to server 38.22.112.236 port 5151 which is .NET Core service. Instead of correct redirection I will get Status 503 Service is Unavailable - No server is available to handle this request.
BTW when I fill https://38.22.112.236:5151/api/asl/msggw in browser , response status code is 200. And content of response is something like this
"gRPC": [
{
"name": "gRPC - ...................................",
"pattern": ".........................",
"order": 0
},
.....
Why it doesn’t work for me msggw2 redirection even though backend server is running and returns 200 Status code ?
Log from haproxy is here:
Jan 30 10:30:52 pfSense haproxy[78524]: Health check for server msggw2_ipvANY/msggw2 failed, reason: Layer7 invalid response, info: "TCPCHK got an empty response at step 2", check duration: 198ms, status: 0/2 DOWN.
Both servers can handle SSL requests.
Thank you for any advice that can help me , solve this issue.