# HAproxy configuration

**URL:** <https://discourse.haproxy.org/t/haproxy-configuration/2568>\
**Category:** Help!\
**Created:** [June 6, 2018, 11:01pm UTC](https://discourse.haproxy.org/t/haproxy-configuration/2568 "2018-06-06T23:01:03Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![miroslav](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@miroslav](https://discourse.haproxy.org/u/miroslav)\
**Post date:** [June 6, 2018, 11:01pm UTC](https://discourse.haproxy.org/t/haproxy-configuration/2568/1 "2018-06-06T23:01:03Z")

</div>

Hi,

I am facing problem to setup HAproxy when it is needed for different directories in URL to reach different backend systems. So, what is needed is when enter

[www.evaplus.com/drs](http://www.evaplus.com/drs) -\> to access backend system

Setting I have is following:

acl host\_www hdr\_beg(host) -i [www.evaplus.com](http://www.evaplus.com)  
acl drs\_hostname path\_beg /drs  
use\_backend backend\_drs if host\_www drs\_hostname  
backend backend\_drs  
mode http  
server backend\_drs 172.16.2.59:8090

When I try to reach above url with ‘/drs’ , it is not possible.  
What is wrong with this setting?

Thank you!  
Miroslav

---

<div class="post-metadata">

**Author:** ![erland](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/erland/32/467_2.png) [@erland](https://discourse.haproxy.org/u/erland)\
**Post date:** [June 7, 2018, 9:04am UTC](https://discourse.haproxy.org/t/haproxy-configuration/2568/2 "2018-06-07T09:04:54Z")

</div>

If i’m not mistaking acl’s are evaluated in order meaning host\_www hdr\_beg(host) -i [www.evaplus.com](http://www.evaplus.com) will be evaluated before acl drs\_hostname path\_beg /drs.

A simple move of the two rules should solve your problem.

Kind regards,  
Erland.

---

<div class="post-metadata">

**Author:** ![miroslav](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@miroslav](https://discourse.haproxy.org/u/miroslav)\
**Post date:** [June 7, 2018, 12:14pm UTC](https://discourse.haproxy.org/t/haproxy-configuration/2568/3 "2018-06-07T12:14:09Z")

</div>

Thank you erland.

I am not sure that I understand how did you mean to move 2 rules.  
I did it in following way:

acl drs\_hostname path\_beg /drs  
acl host\_www hdr\_beg(host) -i [www.evaplus.com](http://www.evaplus.com)  
use\_backend backend\_drs if drs\_hostname host\_www  
backend backend\_drs  
mode http  
server backend\_drs 172.16.2.59:8090

but still does not work. Still cannot reach [www.evaplus.com/drs](http://www.evaplus.com/drs)  
If you meant differently, would you please give me right order I should put the rules.

Thank you!  
Miroslav

---

<div class="post-metadata">

**Author:** ![erland](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/erland/32/467_2.png) [@erland](https://discourse.haproxy.org/u/erland)\
**Post date:** [June 7, 2018, 2:11pm UTC](https://discourse.haproxy.org/t/haproxy-configuration/2568/4 "2018-06-07T14:11:26Z")

</div>

Can you post your complete config please?

---

<div class="post-metadata">

**Author:** ![miroslav](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@miroslav](https://discourse.haproxy.org/u/miroslav)\
**Post date:** [June 7, 2018, 8:55pm UTC](https://discourse.haproxy.org/t/haproxy-configuration/2568/5 "2018-06-07T20:55:47Z")

</div>

global  
log 127.0.0.1 local0 debug  
# log /var/log local0 info  
chroot /var/lib/haproxy  
# user haproxy  
# group haproxy  
maxconn 2000

defaults  
log global  
mode tcp  
option tcplog  
option dontlognull  
timeout connect 500000  
timeout client 500000  
timeout server 500000

userlist hasler  
group adm users admin  
user admin insecure-password Hasler3018

# WEB

##################################################################  
frontend web  
mode http  
bind \*:80  
# Define ACL based on host names  
acl c2c\_hostname hdr(host) -i [c2c.evaplus.com](http://c2c.evaplus.com)  
acl multi\_hostname hdr(host) -i [haslerrail.evaplus.com](http://haslerrail.evaplus.com)  
acl c2c\_ip hdr(host) -i 52.214.141.171

```
    acl host_www hdr_beg(host) -i www.evaplus.com
    acl ussugar_hostname hdr(host) -i ussugar.evaplus.com
    acl adl_hostname hdr(host) -i adl.evaplus.com
    acl nor_hostname hdr(host) -i nor.evaplus.com
    acl int_hostname hdr(host) -i int.evaplus.com
    acl drs_hostname path_beg /drs
            
    # Default Route to normal backends
   
    use_backend backend_ussugar if ussugar_hostname
    use_backend backend_adl if adl_hostname
    use_backend backend_nor if nor_hostname
    use_backend backend_int if int_hostname
    use_backend backend_drs if drs_hostname host_www

```

# default\_backend backend\_sales

backend backend\_c2c  
mode http  
server backend\_c2c 172.16.2.11:8180 check  
server backend\_test 172.16.1.63:8080 check backup

backend backend\_ussugar  
mode http  
server backend\_ussugar 172.16.2.59:8080

backend backend\_adl  
balance roundrobin  
mode http  
server backend\_adl 172.16.2.59:8480 check  
server backend\_adl1 172.16.2.160:8480 check

backend backend\_nor  
mode http  
server backend\_nor 172.16.2.59:8580

backend backend\_int  
mode http  
server backend\_int 172.16.2.59:8180

backend backend\_drs  
mode http  
server backend\_drs 172.16.2.59:8090

Here it is, more or less.  
The problem we are having is that , for each application in backed we would use different subdomain, like:

acl adl\_hostname hdr(host) -i [adl.evaplus.com](http://adl.evaplus.com)  
acl nor\_hostname hdr(host) -i [nor.evaplus.com](http://nor.evaplus.com)  
acl int\_hostname hdr(host) -i [int.evaplus.com](http://int.evaplus.com)

Now, we are running out of free subdomains in [evaplus.com](http://evaplus.com) domain we reserved.  
That is why we want to make routing where will not use subdomain for each backend we need to reach.

I understood from documentation that it should work with

acl drs\_hostname path\_beg /drs  
acl host\_www hdr\_beg(host) -i [www.evaplus.com](http://www.evaplus.com)  
use\_backend backend\_drs if host\_www drs\_hostname

but, something is not ok.

Thank you!

---

<div class="post-metadata">

**Author:** ![erland](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/erland/32/467_2.png) [@erland](https://discourse.haproxy.org/u/erland)\
**Post date:** [June 8, 2018, 4:36am UTC](https://discourse.haproxy.org/t/haproxy-configuration/2568/6 "2018-06-08T04:36:12Z")

</div>

Hi Miroslav,

I understand now.  
Keep in mind that haproxy will proxy all incoming packets for \<whatever\_site\>/drs to 172.16.2.59:8090/drs.  
HAProxy will proxy, dut will not rewrite the url.

Erland.

---

<div class="post-metadata">

**Author:** ![miroslav](https://avatars.discourse-cdn.com/v4/letter/m/a587f6/32.png) [@miroslav](https://discourse.haproxy.org/u/miroslav)\
**Post date:** [June 10, 2018, 10:45pm UTC](https://discourse.haproxy.org/t/haproxy-configuration/2568/7 "2018-06-10T22:45:51Z")

</div>

Hi erland,

I expect when enter, in my case [www.evaplus.com/drs](http://www.evaplus.com/drs) HAproxy to reach 172.16.2.59:8090 - This is where my tomcat is running. (not 172.16.2.59:8090/drs). I also expect that condition,

use\_backend backend\_drs if host\_www drs\_hostname

will provide this.  
Or do you have an idea what I should put differently in order proxy to reach only 172.16.2.59:8090 when someone enter [www.evaplus.com/drs](http://www.evaplus.com/drs)

Thank you!
