Skip to content

Commit

Permalink
Release 1.8-1.7
Browse files Browse the repository at this point in the history
  • Loading branch information
valentinab25 committed Jun 14, 2021
1 parent 6e67bbf commit 6b2b820
Show file tree
Hide file tree
Showing 5 changed files with 44 additions and 38 deletions.
14 changes: 8 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,20 @@
# Changelog

## 2021-06-14 (1.8-1.7)

- Upgrade HAProxy to 1.8.30
- Add `COOKIES_NAME` parameter to configure cookie name
- Add `HTTPCHK_HOST` parameter to allow health check to include host HTTP Header - refs #20

## 2021-03-23 (1.8-1.6)

- Upgrade HAProxy to 1.8.29
- Fixed code to work with new HAProxy configuration location - /usr/local/etc/haproxy/haproxy.cfg
- Fix backend port when DNS_ENABLED - refs #24

## 2020-03-26 (1.8-1.5)

- Add HTTPCHK_HOST variable to allow health check to include "Host: xyz.com" HTTP Header. Defaults to "localhost"
- Fix backend port when `DNS_ENABLED` - refs #24

## 2019-11-28 (1.8-1.5)

- Add COOKIES_PARAMS variable to give the possibility to add expiration time to cookies
- Add `COOKIES_PARAMS` variable to give the possibility to add expiration time to cookies

## 2019-11-22 (1.8-1.4)

Expand Down
2 changes: 1 addition & 1 deletion haproxy/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM haproxy:1.8.29
FROM haproxy:1.8.30
LABEL maintainer="EEA: IDM2 A-Team <eea-edw-a-team-alerts@googlegroups.com>"

RUN apt-get update \
Expand Down
1 change: 1 addition & 0 deletions haproxy/Readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@ either when running the container or in a `docker-compose.yml` file.
* `FRONTEND_MODE` Frontend mode - default `http` or `BACKENDS_MODE` if declared
* `PROXY_PROTOCOL_ENABLED` The option to enable or disable accepting proxy protocol (`true` stands for enabled, `false` or anything else for disabled) - default `false`
* `COOKIES_ENABLED` The option to enable or disable cookie-based sessions (`true` stands for enabled, `false` or anything else for disabled) - default `false`
* `COOKIES_NAME` Will be added on cookie declaration - default `SRV_ID`
* `COOKIES_PARAMS` Will be added on cookie declaration - example `indirect nocache maxidle 30m maxlife 8h` or `maxlife 24h` - documentation https://cbonte.github.io/haproxy-dconv/1.8/configuration.html#4-cookie
* `BACKEND_NAME` The label of the backend - default `http-backend`
* `BACKENDS` The list of `server_ip:server_listening_port` to be load-balanced by HAProxy, separated by space - by default it is not set
Expand Down
57 changes: 29 additions & 28 deletions haproxy/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,15 @@

# haproxy not directly configured within /usr/local/etc/haproxy/haproxy.cfg
if ! test -e /usr/local/etc/haproxy/haproxy.cfg; then
if [ ! -z "$DNS_ENABLED" ]; then
if [ -n "$DNS_ENABLED" ]; then
# Backends are resolved using internal or external DNS service
touch /etc/haproxy/dns.backends
python3 /configure.py dns
echo "*/${DNS_TTL:-1} * * * * /track_dns | logger " > /var/crontab.txt

else

if [ ! -z "$BACKENDS" ]; then
if [ -n "$BACKENDS" ]; then
# Backend provided via $BACKENDS env
python3 /configure.py env
else
Expand All @@ -30,32 +30,33 @@ if ! test -e /usr/local/etc/haproxy/haproxy.cfg; then

#Add env variables for haproxy
echo "export PATH=$PATH"':$PATH' >> /etc/environment
if [ ! -z "$BACKENDS" ]; then echo "export BACKENDS=\"$BACKENDS\"" >> /etc/environment; fi
if [ ! -z "$BACKENDS_PORT" ]; then echo "export BACKENDS_PORT=\"$BACKENDS_PORT\"" >> /etc/environment; fi
if [ ! -z "$BACKENDS_MODE" ]; then echo "export BACKENDS_MODE=\"$BACKENDS_MODE\"" >> /etc/environment; fi
if [ ! -z "$BACKEND_NAME" ]; then echo "export BACKEND_NAME=\"$BACKEND_NAME\"" >> /etc/environment; fi
if [ ! -z "$BALANCE" ]; then echo "export BALANCE=\"$BALANCE\"" >> /etc/environment; fi
if [ ! -z "$COOKIES_ENABLED" ]; then echo "export COOKIES_ENABLED=\"$COOKIES_ENABLED\"" >> /etc/environment; fi
if [ ! -z "$COOKIES_PARAMS" ]; then echo "export COOKIES_PARAMS=\"$COOKIES_PARAMS\"" >> /etc/environment; fi
if [ ! -z "$DOWN_INTER" ]; then echo "export DOWN_INTER=\"$DOWN_INTER\"" >> /etc/environment; fi
if [ ! -z "$FALL" ]; then echo "export FALL=\"$FALL\"" >> /etc/environment; fi
if [ ! -z "$FAST_INTER" ]; then echo "export FAST_INTER=\"$FAST_INTER\"" >> /etc/environment; fi
if [ ! -z "$FRONTEND_NAME" ]; then echo "export FRONTEND_NAME=\"$FRONTEND_NAME\"" >> /etc/environment; fi
if [ ! -z "$FRONTEND_PORT" ]; then echo "export FRONTEND_PORT=\"$FRONTEND_PORT\"" >> /etc/environment; fi
if [ ! -z "$FRONTEND_MODE" ]; then echo "export FRONTEND_MODE=\"$FRONTEND_MODE\"" >> /etc/environment; fi
if [ ! -z "$HTTPCHK" ]; then echo "export HTTPCHK=\"$HTTPCHK\"" >> /etc/environment; fi
if [ ! -z "$HTTPCHK_HOST" ]; then echo "export HTTPCHK_HOST=\"$HTTPCHK_HOST\"" >> /etc/environment; fi
if [ ! -z "$INTER" ]; then echo "export INTER=\"$INTER\"" >> /etc/environment; fi
if [ ! -z "$LOGGING" ]; then echo "export LOGGING=\"$LOGGING\"" >> /etc/environment; fi
if [ ! -z "$LOG_LEVEL" ]; then echo "export LOG_LEVEL=\"$LOG_LEVEL\"" >> /etc/environment; fi
if [ ! -z "$PROXY_PROTOCOL_ENABLED" ]; then echo "export PROXY_PROTOCOL_ENABLED=\"$PROXY_PROTOCOL_ENABLED\"" >> /etc/environment; fi
if [ ! -z "$RISE" ]; then echo "export RISE=\"$RISE\"" >> /etc/environment; fi
if [ ! -z "$SERVICE_NAMES" ]; then echo "export SERVICE_NAMES=\"$SERVICE_NAMES\"" >> /etc/environment; fi
if [ ! -z "$STATS_AUTH" ]; then echo "export STATS_AUTH=\"$STATS_AUTH\"" >> /etc/environment; fi
if [ ! -z "$STATS_PORT" ]; then echo "export STATS_PORT=\"$STATS_PORT\"" >> /etc/environment; fi
if [ ! -z "$TIMEOUT_CLIENT" ]; then echo "export TIMEOUT_CLIENT=\"$TIMEOUT_CLIENT\"" >> /etc/environment; fi
if [ ! -z "$TIMEOUT_CONNECT" ]; then echo "export TIMEOUT_CONNECT=\"$TIMEOUT_CONNECT\"" >> /etc/environment; fi
if [ ! -z "$TIMEOUT_SERVER" ]; then echo "export TIMEOUT_SERVER=\"$TIMEOUT_SERVER\"" >> /etc/environment; fi
if [ -n "$BACKENDS" ]; then echo "export BACKENDS=\"$BACKENDS\"" >> /etc/environment; fi
if [ -n "$BACKENDS_PORT" ]; then echo "export BACKENDS_PORT=\"$BACKENDS_PORT\"" >> /etc/environment; fi
if [ -n "$BACKENDS_MODE" ]; then echo "export BACKENDS_MODE=\"$BACKENDS_MODE\"" >> /etc/environment; fi
if [ -n "$BACKEND_NAME" ]; then echo "export BACKEND_NAME=\"$BACKEND_NAME\"" >> /etc/environment; fi
if [ -n "$BALANCE" ]; then echo "export BALANCE=\"$BALANCE\"" >> /etc/environment; fi
if [ -n "$COOKIES_ENABLED" ]; then echo "export COOKIES_ENABLED=\"$COOKIES_ENABLED\"" >> /etc/environment; fi
if [ -n "$COOKIES_NAME" ]; then echo "export COOKIES_NAME=\"$COOKIES_NAME\"" >> /etc/environment; fi
if [ -n "$COOKIES_PARAMS" ]; then echo "export COOKIES_PARAMS=\"$COOKIES_PARAMS\"" >> /etc/environment; fi
if [ -n "$DOWN_INTER" ]; then echo "export DOWN_INTER=\"$DOWN_INTER\"" >> /etc/environment; fi
if [ -n "$FALL" ]; then echo "export FALL=\"$FALL\"" >> /etc/environment; fi
if [ -n "$FAST_INTER" ]; then echo "export FAST_INTER=\"$FAST_INTER\"" >> /etc/environment; fi
if [ -n "$FRONTEND_NAME" ]; then echo "export FRONTEND_NAME=\"$FRONTEND_NAME\"" >> /etc/environment; fi
if [ -n "$FRONTEND_PORT" ]; then echo "export FRONTEND_PORT=\"$FRONTEND_PORT\"" >> /etc/environment; fi
if [ -n "$FRONTEND_MODE" ]; then echo "export FRONTEND_MODE=\"$FRONTEND_MODE\"" >> /etc/environment; fi
if [ -n "$HTTPCHK" ]; then echo "export HTTPCHK=\"$HTTPCHK\"" >> /etc/environment; fi
if [ -n "$HTTPCHK_HOST" ]; then echo "export HTTPCHK_HOST=\"$HTTPCHK_HOST\"" >> /etc/environment; fi
if [ -n "$INTER" ]; then echo "export INTER=\"$INTER\"" >> /etc/environment; fi
if [ -n "$LOGGING" ]; then echo "export LOGGING=\"$LOGGING\"" >> /etc/environment; fi
if [ -n "$LOG_LEVEL" ]; then echo "export LOG_LEVEL=\"$LOG_LEVEL\"" >> /etc/environment; fi
if [ -n "$PROXY_PROTOCOL_ENABLED" ]; then echo "export PROXY_PROTOCOL_ENABLED=\"$PROXY_PROTOCOL_ENABLED\"" >> /etc/environment; fi
if [ -n "$RISE" ]; then echo "export RISE=\"$RISE\"" >> /etc/environment; fi
if [ -n "$SERVICE_NAMES" ]; then echo "export SERVICE_NAMES=\"$SERVICE_NAMES\"" >> /etc/environment; fi
if [ -n "$STATS_AUTH" ]; then echo "export STATS_AUTH=\"$STATS_AUTH\"" >> /etc/environment; fi
if [ -n "$STATS_PORT" ]; then echo "export STATS_PORT=\"$STATS_PORT\"" >> /etc/environment; fi
if [ -n "$TIMEOUT_CLIENT" ]; then echo "export TIMEOUT_CLIENT=\"$TIMEOUT_CLIENT\"" >> /etc/environment; fi
if [ -n "$TIMEOUT_CONNECT" ]; then echo "export TIMEOUT_CONNECT=\"$TIMEOUT_CONNECT\"" >> /etc/environment; fi
if [ -n "$TIMEOUT_SERVER" ]; then echo "export TIMEOUT_SERVER=\"$TIMEOUT_SERVER\"" >> /etc/environment; fi
fi


Expand Down
8 changes: 5 additions & 3 deletions haproxy/src/configure.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
BALANCE = os.environ.get('BALANCE', 'roundrobin')
SERVICE_NAMES = os.environ.get('SERVICE_NAMES', '')
COOKIES_ENABLED = (os.environ.get('COOKIES_ENABLED', 'false').lower() == "true")
COOKIES_NAME = os.environ.get('COOKIES_NAME','SRV_ID')
COOKIES_PARAMS = os.environ.get('COOKIES_PARAMS','')
PROXY_PROTOCOL_ENABLED = (os.environ.get('PROXY_PROTOCOL_ENABLED', 'false').lower() == "true")
STATS_PORT = os.environ.get('STATS_PORT', '1936')
Expand Down Expand Up @@ -54,15 +55,15 @@

if COOKIES_ENABLED:
#if we choose to enable session stickiness
#then insert a cookie named SRV_ID to the request:
#then insert a cookie named $COOKIES_NAME(SRV_ID) to the request:
#all responses from HAProxy to the client will contain a Set-Cookie:
#header with a specific value for each backend server as its cookie value.
backend_conf = Template("""
backend $backend
mode $mode
balance $balance
default-server inter $inter fastinter $fastinter downinter $downinter fall $fall rise $rise
cookie SRV_ID insert $cookies_params
cookie $cookies_name insert $cookies_params
""")
cookies = "cookie \\\"@@value@@\\\""
else:
Expand All @@ -74,7 +75,7 @@
mode $mode
balance $balance
default-server inter $inter fastinter $fastinter downinter $downinter fall $fall rise $rise
cookie SRV_ID prefix $cookies_params
cookie $cookies_name prefix $cookies_params
""")
cookies = ""

Expand Down Expand Up @@ -103,6 +104,7 @@
downinter=DOWN_INTER,
fall=FALL,
rise=RISE,
cookies_name=COOKIES_NAME,
cookies_params=COOKIES_PARAMS
)

Expand Down

0 comments on commit 6b2b820

Please sign in to comment.