1

Following config file work as expect but do duplicate health-check for the real same proxy-server, how can I avoid such duplicate health-check? (I still want do health-check but not duplicate health-check)

global
    external-check
defaults
    option httplog
    log 127.0.0.1:514 user
    timeout connect 5000s
    timeout client 5000s
    timeout server 5000s
#Close the using connection when backend server marked as down
listen main-proxy1
    bind 127.0.0.1:8079
    mode http
    option external-check
    external-check command /checker
    balance static-rr
    server proxy1 127.0.0.1:9999 check on-marked-down shutdown-sessions on-marked-up shutdown-backup-sessions
#Don't close the using connection when backend server marked as down
listen main-proxy2
    bind 127.0.0.1:8080
    mode http
    option external-check
    external-check command /checker
    balance static-rr
    server proxy2 127.0.0.1:9999 check
illiterate
  • 149
  • 7
  • What's the point of configuring two proxies to the same backend in the first place? – Gerald Schneider Mar 07 '19 at 08:16
  • @GeraldSchneider `What's the point` I want to distinguish two application type, some applications want to close the using connection and failover/balance immediately when servers go to down, and others want to keep the using connection as possible. – illiterate Mar 07 '19 at 08:23

2 Answers2

3

You can use the track directive to follow the status of another server. In your case the second server line would be:

server proxy2 127.0.0.1:9999 track main-proxy1/proxy1
wurtel
  • 3,864
  • 12
  • 15
1

I think the most easier way to solve this is to define a frontend and a backend:

example:

frontend www.mysite.com
    bind 10.0.0.3:80
    bind 10.0.0.3:443 ssl crt /etc/ssl/certs/mysite.pem
    http-request redirect scheme https unless { ssl_fc }
    use_backend api_servers if { path_beg /api/ }
    default_backend web_servers

backend web_servers
    balance roundrobin
    cookie SERVERUSED insert indirect nocache
    option httpchk HEAD /
    default-server check maxconn 20
    server server1 10.0.1.3:80 cookie server1
    server server2 10.0.1.4:80 cookie server2

You will have the healthcheck in the backend and Now you can use the same backend for multiple frontends.

c4f4t0r
  • 5,301
  • 3
  • 31
  • 42