# Redirect URL or sub folders

**URL:** <https://discourse.haproxy.org/t/redirect-url-or-sub-folders/7851>\
**Category:** Help!\
**Created:** [July 20, 2022, 11:30am UTC](https://discourse.haproxy.org/t/redirect-url-or-sub-folders/7851 "2022-07-20T11:30:20Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![tad](https://avatars.discourse-cdn.com/v4/letter/t/278dde/32.png) [@tad](https://discourse.haproxy.org/u/tad)\
**Post date:** [July 20, 2022, 11:30am UTC](https://discourse.haproxy.org/t/redirect-url-or-sub-folders/7851/1 "2022-07-20T11:30:20Z")

</div>

I am a newb to HAProxy, I have a website and several applications, the web page is [https://audit.mydomain.com](https://audit.mydomain.com) and the applications are api, gsdev  
I want to get to this [https://audit.mydomain.com/api](https://audit.mydomain.com/api) and [https://audit.mydomain.com/gsdev](https://audit.mydomain.com/gsdev) and add applications.

I have programmed in different ways but I can’t find the solution, I appreciate the help you can give me, this is my programming:

#---------------------------------------------------------------------

# FrontEnd Configuration

#---------------------------------------------------------------------  
frontend master  
bind \*:80  
option forwardfor  
reqadd X-Forwarded-Proto:\ http  
redirect scheme https code 301 if !{ ssl\_fc }

frontend master\_https  
bind \*:443 ssl crt /etc/haproxy/ssl-myssl/myssl.pem  
rspadd Strict-Transport-Security:\ max-age=31536000  
option forwardfor  
http-request deny if HTTP\_1.0  
http-request deny if { req.hdr(user-agent) -i -m sub curl phantomjs slimerjs }  
http-request deny unless { req.hdr(user-agent) -m found }  
reqadd X-Forward-Proto:\ https

```
acl host_web hdr(host) -i webtest.mydomain.com
use_backend webtest if host_web

acl gsdev_url hdr(host) -i gsdev.mydomain.com
use_backend gsapi if gsdev_url

acl audit_url hdr(host) -i audit.mydomain.com
use_backend audit if audit_url

acl url_api hdr(host) -i api.mydomain.com/api
use_backend api if url_api

```

#--------------------------------------------------------------

# acl sub\_api path\_end -i /api

# use\_backend api if sub\_api

#-----------------------------------------------------------------

```
default_backend webtest

```

#---------------------------------------------------------------------

# BackEnd Configuration

#---------------------------------------------------------------------  
backend webtest  
balance roundrobin  
option httpchk HEAD / HTTP/1.1\r\nHost:\ localhost

```
server slave1 10.10.2.45:8089 check
server slave2 10.10.2.56:8089 check
server slave1 10.10.2.45:443 backup check

```

backend gsapi  
balance roundrobin  
cookie gsapi\_cook insert nocache  
option forwardfor  
http-request set-header X-Forwarded-Port %[dst\_port]  
http-request add-header X-Forwarded-Proto https if { ssl\_fc }  
option httpchk HEAD / HTTP/1.1\r\nHost:\ localhost

```
server slave1 10.10.2.45:5000 check cookie slave1
server slave2 10.10.2.56:5000 check cookie slave2
server slave1 10.10.2.45:443 backup check

```

backend api  
balance roundrobin  
option httpchk HEAD / HTTP/1.1\r\nHost:\ localhost

# reqrep ^([^\ :]_)\ /api:_[/]?(.\*) \1\ /\2

# reqirep ^([^\ :]_)\ /app-2/(._) \1\ /app-2-another-path/\2

# reqirep ^([^\ :]_)\ /api/(._) \1\ /api/\2

# reqirep ^([^\ :]\*)\ /api/ \1\ /api

```
server slave1 10.10.2.45:5005/api check
server slave2 10.10.2.56:5005/api check
server slave1 10.10.2.45:443 backup check

```

backend audit  
balance source  
option httpchk HEAD / HTTP/1.1\r\nHost:\ localhost

```
server slave2 10.10.2.56:5010 check
server slave1 10.10.2.45:443 backup check

```
