まず二つのことが簡単で、単に第三のみホワイトリストIP
acl whitelist src 10.12.12.23
use_backend SOMESERVER if whitelist
許可 - スロットリング - stick-tablesを使用する必要が(多くのデータタイプがある - カウンタはconnの、SESのは、HTTP、レートカウンタとして速度...):
# max entries count request in 60s periods
stick-table type ip size 200k expire 100s store http_req_rate(60s)
はあなたの隣には、tracking each requestなどにより、テーブルを埋めるために持っています。例えば
# is there more than 5req/1min from IP
acl http_rate_abuse sc0_http_req_rate gt 5
# update use_backend condition
use_backend SOMESERVER if whitelisted !http_rate_abuse
カスタマイズされたエラーが発生しているいくつかの作業設定ファイル::
global
log /dev/log local1 debug
defaults
log global
mode http
option httplog
retries 3
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
srvtimeout 50000
frontend http
bind *:8181
stick-table type ip size 200k expire 100s store http_req_rate(60s)
tcp-request content track-sc0 src
acl whitelist src 127.0.0.1
acl http_rate_abuse sc0_http_req_rate gt 5
use_backend error401 if !whitelist
use_backend error429 if http_rate_abuse
use_backend realone
backend realone
server local stackoverflow.com:80
# too many requests
backend error429
mode http
errorfile 503 /etc/haproxy/errors/429.http
# unauthenticated
backend error401
mode http
errorfile 503 /etc/haproxy/errors/401.http
注:エラーハンドリングは少しトリッキーですIP
tcp-request content track-sc0 src
# more info at http://cbonte.github.io/haproxy-dconv/1.5/configuration.html#4.2-tcp-request%20connection
、最終的には、ACLで。上記のエラーバックエンドにはサーバーエントリがないため、haproxyはHTTP 503、errorfile
をキャッチして異なるエラーを(異なるコードで)送信します。
例/etc/haproxy/errors/401.http
内容:
HTTP/1.0 401 Unauthenticated
Cache-Control: no-cache
Connection: close
Content-Type: text/html
<html><body><h1>401 Unauthenticated</h1>
</body></html>
例/etc/haproxy/errors/429.http
内容:
HTTP/1.0 429 Too many requests
Cache-Control: no-cache
Connection: close
Content-Type: text/html
<html><body><h1>429 Too many requests</h1>
</body></html>
あなたは、この時の試みを作り、あなたが動けなくなるところ私たちを表示する必要があります。 HAProxyの設定ファイルには、あるレベルの「プログラミング」が含まれている可能性がありますが、[Server Fault](http://serverfault.com)がHAProxyの質問に対するStack Overflowよりも適切な場所であると思われます。 –