I am a newb to HAProxy, and am bashing my head against this one. I’m trying to set up what I think is a fairly simple exercise in mapping applications listening on various ports to specific URLs.Like if my app page-designer is listening at http://IP:30000,then i would like to map it to http://IP/page-designer.I know i have asked a similar question before.But this time, the question is actually a little different.Upon doing some research,I heard that this can be done using http-request redirect or by adding reqrep ^([^\ ])\ /page-designer(.) \1\ \2 in the backend.


        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

        # 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-options no-sslv3

        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

frontend http-in
    mode    http


    acl path-page-designer              path_beg -i /page-designer
    use_backend page-designer-backend   if path-page-designer

backend page-designer-backend
    mode    http

    option  httplog
    option  forwardfor

    server  appserver1

hitting shows me the apache tomcat homepage.But hitting shows me "HTTP Status 404 - /page-designer the requested resource is not available".So how should i modify my haproxy.cfg to use http-request redirect or http-request set-path to rewrite the requested path.I have also tried this with another node js app running on port 5000,but that time instead of 404 error i was getting "Cannot GET /page-designer".So i am sure what is actually going wrong here.Plz help?

  • is this the only page/purpose you host with ha proxy? if yes nginx is easier to config in my point of View... – djdomi Sep 7 '19 at 17:02
  • no actually this is not the only page and i want to use only haproxy for this!! – Vignesh Swaminathan Sep 8 '19 at 3:45

In your backend, use

http-request set-path %[path,regsub(/page-designer(.*),\1)]

This should do a regexp substitution to remove /page-designer from your path

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.