# Use backend server based on past response status codes

**URL:** <https://discourse.haproxy.org/t/use-backend-server-based-on-past-response-status-codes/7220>\
**Category:** Help!\
**Created:** [December 17, 2021, 3:19am UTC](https://discourse.haproxy.org/t/use-backend-server-based-on-past-response-status-codes/7220 "2021-12-17T03:19:55Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![bistami](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@bistami](https://discourse.haproxy.org/u/bistami)\
**Post date:** [December 17, 2021, 3:19am UTC](https://discourse.haproxy.org/t/use-backend-server-based-on-past-response-status-codes/7220/1 "2021-12-17T03:19:55Z")

</div>

Hello,  
It is possible to use backend server based on response status codd in the past. For example domain [example.com](http://example.com) get error 403,503 on backend server 1.1.1.1 how can i tell haproxy to not use this server for this domain on future requests. Pls Help.

BR

---

<div class="post-metadata">

**Author:** ![rhada](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/rhada/32/585_2.png) [@rhada](https://discourse.haproxy.org/u/rhada)\
**Post date:** [December 17, 2021, 4:07pm UTC](https://discourse.haproxy.org/t/use-backend-server-based-on-past-response-status-codes/7220/2 "2021-12-17T16:07:48Z")

</div>

Hello,

You have to use the health check. You can just use the default check or provide additional options to perform a custom check on specific url for example :

```auto
backend be_server
    option httpchk GET /httpchk HTTP/1.1
    http-check expect status 200
    server server01 127.0.0.1:8080 check

```

---

<div class="post-metadata">

**Author:** ![bistami](https://avatars.discourse-cdn.com/v4/letter/b/85f322/32.png) [@bistami](https://discourse.haproxy.org/u/bistami)\
**Post date:** [December 17, 2021, 4:55pm UTC](https://discourse.haproxy.org/t/use-backend-server-based-on-past-response-status-codes/7220/3 "2021-12-17T16:55:07Z")

</div>

Ok thank you and i will map backend by domain name this config works only if target site is http.

```auto

  # ACL for "example.com" and "www.example.com"
  acl ACL_example.com hdr(host) -i example.com www.example.com
  use_backend be_example.com if ACL_example.com

  # ACL for "example.net"
  acl ACL_example.net hdr(host) -i example.net
  use_backend be_example.net if ACL_example.net

```

fallback every time default backend. But i will that it works on target https sites too. is there a way to map backend by domain name if targeting https sites too without configuring ssl cert. tried openssl on port 443 on 127.0.0.1 but get error self signed. What i want is  
127.0.0.1:5555 —\> map backend by domain —\> backend for domain [https://example.com](https://example.com) pls help

---

<div class="post-metadata">

**Author:** ![rhada](https://sea2.discourse-cdn.com/flex016/user_avatar/discourse.haproxy.org/rhada/32/585_2.png) [@rhada](https://discourse.haproxy.org/u/rhada)\
**Post date:** [December 20, 2021, 11:11am UTC](https://discourse.haproxy.org/t/use-backend-server-based-on-past-response-status-codes/7220/4 "2021-12-20T11:11:24Z")

</div>

Hello,

I really don’t understand what you are trying to do.

You want a http frontend with a https backend ? Are the user reaching you with http or https ?
