-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Alexander Piskun <[email protected]> Co-authored-by: Alexander Piskun <[email protected]>
- Loading branch information
1 parent
905d6c3
commit 0959353
Showing
6 changed files
with
118 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,28 @@ | ||
frontend ex_apps | ||
mode http | ||
bind *:23000-23999 v4v6 ssl crt /certs/cert.pem | ||
BIND_ADDRESS_PLACEHOLDER | ||
|
||
# Rate limiting | ||
stick-table type ip size 1m expire 1440m store http_err_cnt,http_err_rate(60m) | ||
# ACL to restrict rate limited request | ||
acl acl-www-err-rate sc_http_err_rate(0) gt 5 | ||
acl acl-www-err-total sc_http_err_cnt(0) gt 10 | ||
stick-table type ip size 100k expire 144m store gpc0,http_req_rate(5m) | ||
|
||
http-request track-sc0 src | ||
http-request deny if acl-www-err-total | ||
http-request silent-drop if acl-www-err-rate | ||
# Perform Basic Auth | ||
acl valid_credentials http_auth(app_api_credentials) | ||
|
||
# Basic Authentication | ||
http-request auth unless { http_auth(app_api_credentials) } | ||
# Increase counter on failed authentication | ||
http-request track-sc0 src if ! valid_credentials | ||
http-request sc-inc-gpc0(0) if ! valid_credentials | ||
|
||
# Check if the client IP has more than 5 failed attempts in the last 5 minutes | ||
acl too_many_auth_failures sc0_http_req_rate gt 5 | ||
|
||
# Use 'silent-drop' to drop the connection without a response | ||
http-request silent-drop if too_many_auth_failures | ||
|
||
http-request auth realm AppAPI unless valid_credentials | ||
|
||
# We allow anything for ExApps | ||
http-request allow | ||
use_backend bk_ex_apps | ||
|
||
backend bk_ex_apps | ||
mode http | ||
server ex_apps EX_APPS_NET_PLACEHOLDER | ||
server ex_apps EX_APPS_NET_FOR_HTTPS_PLACEHOLDER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
#!/bin/sh | ||
|
||
set -x | ||
HAPROXYFILE="$(sed "s|NC_PASSWORD_PLACEHOLDER|$NC_HAPROXY_PASSWORD|" /haproxy.cfg)" | ||
HAPROXYFILE="$(echo "$HAPROXYFILE" | sed "s|HAPROXY_PORT_PLACEHOLDER|$HAPROXY_PORT|")" | ||
sed -i "s|NC_PASSWORD_PLACEHOLDER|$NC_HAPROXY_PASSWORD|" /haproxy.cfg | ||
|
||
if [ -f "/certs/cert.pem" ]; then | ||
HAPROXYFILE="$(echo "$HAPROXYFILE" | sed "s|BIND_DOCKER_PLACEHOLDER|bind *:$HAPROXY_PORT v4v6 ssl crt /certs/cert.pem|")" | ||
sed -i "s|EX_APPS_NET_PLACEHOLDER|$EX_APPS_NET|" /haproxy_ex_apps.cfg | ||
sed -i "s|BIND_ADDRESS_PLACEHOLDER|bind $BIND_ADDRESS:$HAPROXY_PORT v4v6 ssl crt /certs/cert.pem|" /haproxy.cfg | ||
sed -i "s|BIND_ADDRESS_PLACEHOLDER|bind $BIND_ADDRESS:23000-23999 v4v6 ssl crt /certs/cert.pem|" /haproxy_ex_apps.cfg | ||
sed -i "s|EX_APPS_NET_FOR_HTTPS_PLACEHOLDER|$EX_APPS_NET_FOR_HTTPS|" /haproxy_ex_apps.cfg | ||
# Chmod certs to be accessible by haproxy | ||
chmod 644 /certs/cert.pem | ||
else | ||
HAPROXYFILE="$(echo "$HAPROXYFILE" | sed "s|BIND_DOCKER_PLACEHOLDER|bind *:$HAPROXY_PORT v4v6|")" | ||
sed -i "s|BIND_ADDRESS_PLACEHOLDER|bind $BIND_ADDRESS:$HAPROXY_PORT v4v6|" /haproxy.cfg | ||
fi | ||
echo "$HAPROXYFILE" > /haproxy.cfg | ||
|
||
set +x | ||
echo "HaProxy config:" | ||
|
||
if [ -f "/certs/cert.pem" ]; then | ||
cat /haproxy.cfg | ||
cat /haproxy_ex_apps.cfg | ||
haproxy -f /haproxy.cfg -f /haproxy_ex_apps.cfg -db | ||
else | ||
cat /haproxy.cfg | ||
haproxy -f /haproxy.cfg -db | ||
fi |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters