How to use HAProxy to change how users get repointed to our locally hosted websites

Hello Team,

I’m very new to using HAProxy but I’ve managed with some help to successfully setup HAProxy version 1.8.15 on my CentOS 8 server. I have within my /etc/haproxy/haproxy.cfg file added in the required frontend and backend entries to point to various webapps our office hosts locally:

Sites are examples below and not real domains we own.

frontend front_mysites
        mode http
        bind 10.101.0.10:443 ssl crt /etc/pki/tls/certs/star_cert.crt
        option httplog
        log     global

        use_backend back_nextcloud if { hdr(host) -i mycloud.myoffice.com }
        use_backend back_mail if { hdr(host) -i mymail.myoffice.com }

backend back_nextcloud
        mode    http
        option  forwardfor
        option  http-server-close
        http-response set-header Strict-Transport-Security max-age=16000000;\ includeSubDomains;\ preload;
        server nextcloud-01 10.101.0.11:443 check ssl verify none

backend back_mail
        mode    http
        option  forwardfor
        option  http-server-close
        http-response set-header Strict-Transport-Security max-age=16000000;\ includeSubDomains;\ preload;
        server webtop-01 10.101.0.12:443 check ssl verify none

Typcially we access our locally hosted sites using something like the following addresses:

Domain request | CSC
Domain request | CSC

What I would like to have happen instead is our users type in the following addresses to access our websites and not have them enter in the name after the /:

mymail.myoffice.com
mycloud.myoffice.com

Can our HAProxy be configured to assist us so that when a user types in for example mymail.myoffice.com they are redirected to Domain request | CSC?

Thank you in advance for any advice you can provide me.

Hello forum,

Does anyone have some ideas for me that I could test out to achieve what I need through HAProxy?

Thank you.

Have you tried reqirep?
Something like:

acl nexcloud if hdr(host) -i mycloud.myoffice.com
reqirep ^([^\ ]*\ / \1/nextcloud if nextcloud

Further details can be found http://cbonte.github.io/haproxy-dconv/configuration-1.5.html#4-reqirep

1 Like

Hello Team,

I’ve discovered the solution to my issue. Thank you @void_in for pointing me in the right direction. I used the folloiwng ACL to add in the name of the page after the “/”:

    acl nextcloud_path path -i /
    http-request set-path /nextcloud if nextcloud_path

Thanks!

1 Like