IIS 503 HAProxy NextJS

My app is running normally on IIS Windows. It’s a NextJS app set with basePath = /minisom. When I access the IIS 192… website, everything works normally. However, when I install HAProxy with these same settings, I keep getting 400, 503 errors until it updates and works (sometimes). Sometimes on the login page when I type my email and password, it shows my email and password in the URL. When the app works, a few minutes pass and it stops working again.

global
log /dev/log local0
log /dev/log local1 notice
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

# Default SSL material locations
ca-base /etc/ssl/certs
crt-base /etc/ssl/private

# Default ciphers to use on SSL-enabled listening sockets.
# For more information, see ciphers(1SSL). This list is from:
#  https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/
# An alternative list with additional directives can be obtained from
#  https://mozilla.github.io/server-side-tls/ssl-config-generator/?server=haproxy
ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS
#ssl-default-bind-options no-sslv3
ssl-default-bind-options ssl-min-ver TLSv1.2 no-tls-tickets

# Additional generic tuning
tune.ssl.default-dh-param 2048
tune.ssl.cachesize 100000
maxconn 80000
nbproc 1
nbthread 2
cpu-map auto:1/1-2 0-1

defaults
log global
mode http
option httplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
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

# Additional generic tuning
maxconn 80000
timeout tunnel 12h
option forwardfor except 127.0.0.0/8
stats enable
stats auth admin:n0ts03@5y
stats hide-version
stats show-node
stats refresh 10s
stats uri /haproxy?stats

# For HAProxy 2.0 and uCI 8.5
no option http-use-htx

###################

Main entrypoint

###################

frontend altitude_app_server_nossl
bind *:80

#use_backend catch_all_invalid unless { hdr(host) -i 192.168.0.164 || hdr(host) -i haproxy }

acl host_pro                hdr(host) -i 192.168.0.164
acl url_uSupervisorWebApp   path_beg -i /uSupervisorWebApp
acl url_XperienceRouting    path_beg -i /XperienceRouting8
acl url_uAgentWeb           path_beg -i /uAgentWeb /uAgentWeb8 /uAgentWeb8ASLRunner /WebRTCPhoneService/ws /WebRTCPhoneService /rabbitPublisher
acl url_SmasAlmada		path_beg -i /smasalmada
acl url_devminison		path_beg -i /minisom	

# PRO
#use_backend pro_usupervisorwebapp_app_backend   if host_pro url_uSupervisorWebApp
#use_backend pro_xperiencerouting_app_backend    if host_pro url_XperienceRouting
#use_backend pro_swagger_app_backend             if host_pro url_Swagger
use_backend pro_uagentwebrtc_app_backend         if host_pro url_uAgentWeb
use_backend pro_smsalmada_app_backend	     if host_pro url_SmasAlmada
use_backend pro_devminison_app_backend	     if host_pro url_devminison 

acl url_devminison path_beg -i /minisom
use_backend pro_devminison_app_backend if host_pro url_devminison

backend pro_devminison_app_backend
#option http-keep-alive
#option httpchk HEAD /minisom “HTTP/1.0\r\nHOST: agent.tejo.cc”
http-request set-header X-Real-IP %[src]
#http-request set-header X-ORIGIN-URL http://%[hdr(host)]%[path]
#server s1 127.0.0.1:1203 cookie s1 check addr 192.168.2.92 port 80
server s1 192.168.2.92:80 check
timeout server 20m

backend catch_all_invalid

frontend n1_pro_frontend_dev
bind 127.0.0.1:1203
use_backend n1_pro_dev_srv if { path -i -m beg /minisom }
default_backend n1_pro_dev_srv

backend n1_pro_dev_srv
#reqrep ^([^\ :])\ /minisom/(.) \1\ /\2
http-request set-path /%[path]
server s1 192.168.2.92:80 check