HAProxy community

HAProxy backend server respond with different URI than the acl path_beg

I have configured HAProxy as below:

    acl has_env_appslogs path_beg -i /test
    use_backend backend_env_pool_appslogs if has_env_appslogs

    backend backend_env_pool_appslogs
        server env_APP_Logs_2 <hostname>:9999 check

when I browse https://<haproxy_host>/test it brings me to the backend server’s login page.
After entering user & pass in the login page … it generates a HTTP POST request to https://<haproxy_host>/login …. which can’t handle HAProxy. It says below:
[ 503 Service Unavailable
No server is available to handle this request.]

How can I handle this in HAProxy [Like in the middle of backend server communication] ?

Similar request : Rewrite urls for response with absolute urls

Hi !
I finally found someone who handle the same issue as me ! I was googling during hour but found only Ngix solutions…
I’m trying to configure a splunk but like you because of absolute url i’m request content without the prefix (/test) or for me ("/MySplunk") so can’t find the good page.
If you find out what we need to do could you notify me please ? :stuck_out_tongue:

Good weekend !

Use different hostnames or configure your backend application in a way to let it know it doesn’t run in the root path /.

Otherwise you’d have to rewrite the entire HTML content, cookies, etc, which haproxy will not do.

1 Like

Thanks ! But i don’t know how to ‘chroot’ my web application that’s why i was looking for Haproxy solution…
Thanks by the way !

Haproxy will not do that for you.

1 Like

It was an easy solution for me.

In the ACL I have added multiple path(URI) to use the same backend.

acl has_env_appslogs path_beg  /test /login
    use_backend backend_env_pool_appslogs if has_env_appslogs

    backend backend_env_pool_appslogs
        server env_APP_Logs_2 <hostname>:9999 check

Reference: http://cbonte.github.io/haproxy-dconv/1.8/configuration.html#7.2

That’s works as long as the application does not use absolute links or cookies with specific paths.

Yes… My application does not use absolute links and there is no path specific cookie.

1 Like