HAProxy community

Move nginx to HAProxy config problem

#1

Hi!
I trying to change proxy/balancer from nginx to HAProxy, but something wrong with my config, and web page is blank(but title correct).

nginx config:

listen       443 ssl http2;
...
location / {
    proxy_pass http://10.10.2.2:9310/;
}
location /api/
    proxy_pass http://10.10.2.2:9301/api/2/;
}

HAProxy config:

frontend https
   bind      :443 ssl crt /certs/path alpn h2,http/1.1
   acl root           path -i   /
   use_backend root_ if root
   acl api            path_beg  /api/
   use_backend api_ if api

backend root_
   balance roundrobin
   server back1 10.10.2.2:9310 cookie r1 check
   server back2 10.10.2.3:9310 cookie r2 check

backend api_
  balance roundrobin
  http-request set-uri %[url,regsub(^/api/,/api/2/,)]
  server back1 10.10.2.2:9301 cookie a1 check
  server back2 10.10.2.3:9301 cookie a2 check

What have I done wrong?

0 Likes

#2

Check your logs, understand what the URI looks like when it hits the server.

0 Likes