I've got such a configuration in my `haproxy.cfg` file:

```
    acl is_api url_beg -i /api
    acl is_frontend hdr(host) -i subdomain.mydomain.com

    use_backend api if is_api
    use_backend nginx-frontend if is_frontend

```

My goal:

Hitting `subdomain.mydomain.com` will serve files using `nginx` unless the `path` starts with `/api` (`subdomain.mydomain.com/api/*`) - then it should use my `api` backend.

Now, using the current configuration, when I restart `haproxy` service, there are two scenarios:

1. I go to `subdomain.mydomain.com` - it's serving `nginx-frontend` - great. Then I go to `subdomain.mydomain.com/api` - 404 (`nginx` was used).
2. I go to `subdomain.mydomain.com/api` it's serving `api` - great. Then I go to `subdomain.mydomain.com` - 404 (the `api` backend was used).

So depending on the order of my first visit on either page, all the requests to my subdomain are assigned to either backend...

I'm a total newbie, I'm sorry if that's a stupid question.

Any help?