Skip to content

Commit 6b2b820

Browse files
author
valentinab25
committed
Release 1.8-1.7
1 parent 6e67bbf commit 6b2b820

5 files changed

Lines changed: 44 additions & 38 deletions

File tree

CHANGELOG.md

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,20 @@
11
# Changelog
22

3+
## 2021-06-14 (1.8-1.7)
4+
5+
- Upgrade HAProxy to 1.8.30
6+
- Add `COOKIES_NAME` parameter to configure cookie name
7+
- Add `HTTPCHK_HOST` parameter to allow health check to include host HTTP Header - refs #20
8+
39
## 2021-03-23 (1.8-1.6)
410

511
- Upgrade HAProxy to 1.8.29
612
- Fixed code to work with new HAProxy configuration location - /usr/local/etc/haproxy/haproxy.cfg
7-
- Fix backend port when DNS_ENABLED - refs #24
8-
9-
## 2020-03-26 (1.8-1.5)
10-
11-
- Add HTTPCHK_HOST variable to allow health check to include "Host: xyz.com" HTTP Header. Defaults to "localhost"
13+
- Fix backend port when `DNS_ENABLED` - refs #24
1214

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

15-
- Add COOKIES_PARAMS variable to give the possibility to add expiration time to cookies
17+
- Add `COOKIES_PARAMS` variable to give the possibility to add expiration time to cookies
1618

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

haproxy/Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
FROM haproxy:1.8.29
1+
FROM haproxy:1.8.30
22
LABEL maintainer="EEA: IDM2 A-Team <eea-edw-a-team-alerts@googlegroups.com>"
33

44
RUN apt-get update \

haproxy/Readme.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ either when running the container or in a `docker-compose.yml` file.
134134
* `FRONTEND_MODE` Frontend mode - default `http` or `BACKENDS_MODE` if declared
135135
* `PROXY_PROTOCOL_ENABLED` The option to enable or disable accepting proxy protocol (`true` stands for enabled, `false` or anything else for disabled) - default `false`
136136
* `COOKIES_ENABLED` The option to enable or disable cookie-based sessions (`true` stands for enabled, `false` or anything else for disabled) - default `false`
137+
* `COOKIES_NAME` Will be added on cookie declaration - default `SRV_ID`
137138
* `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
138139
* `BACKEND_NAME` The label of the backend - default `http-backend`
139140
* `BACKENDS` The list of `server_ip:server_listening_port` to be load-balanced by HAProxy, separated by space - by default it is not set

haproxy/docker-entrypoint.sh

Lines changed: 29 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -4,15 +4,15 @@
44

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

1313
else
1414

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

3131
#Add env variables for haproxy
3232
echo "export PATH=$PATH"':$PATH' >> /etc/environment
33-
if [ ! -z "$BACKENDS" ]; then echo "export BACKENDS=\"$BACKENDS\"" >> /etc/environment; fi
34-
if [ ! -z "$BACKENDS_PORT" ]; then echo "export BACKENDS_PORT=\"$BACKENDS_PORT\"" >> /etc/environment; fi
35-
if [ ! -z "$BACKENDS_MODE" ]; then echo "export BACKENDS_MODE=\"$BACKENDS_MODE\"" >> /etc/environment; fi
36-
if [ ! -z "$BACKEND_NAME" ]; then echo "export BACKEND_NAME=\"$BACKEND_NAME\"" >> /etc/environment; fi
37-
if [ ! -z "$BALANCE" ]; then echo "export BALANCE=\"$BALANCE\"" >> /etc/environment; fi
38-
if [ ! -z "$COOKIES_ENABLED" ]; then echo "export COOKIES_ENABLED=\"$COOKIES_ENABLED\"" >> /etc/environment; fi
39-
if [ ! -z "$COOKIES_PARAMS" ]; then echo "export COOKIES_PARAMS=\"$COOKIES_PARAMS\"" >> /etc/environment; fi
40-
if [ ! -z "$DOWN_INTER" ]; then echo "export DOWN_INTER=\"$DOWN_INTER\"" >> /etc/environment; fi
41-
if [ ! -z "$FALL" ]; then echo "export FALL=\"$FALL\"" >> /etc/environment; fi
42-
if [ ! -z "$FAST_INTER" ]; then echo "export FAST_INTER=\"$FAST_INTER\"" >> /etc/environment; fi
43-
if [ ! -z "$FRONTEND_NAME" ]; then echo "export FRONTEND_NAME=\"$FRONTEND_NAME\"" >> /etc/environment; fi
44-
if [ ! -z "$FRONTEND_PORT" ]; then echo "export FRONTEND_PORT=\"$FRONTEND_PORT\"" >> /etc/environment; fi
45-
if [ ! -z "$FRONTEND_MODE" ]; then echo "export FRONTEND_MODE=\"$FRONTEND_MODE\"" >> /etc/environment; fi
46-
if [ ! -z "$HTTPCHK" ]; then echo "export HTTPCHK=\"$HTTPCHK\"" >> /etc/environment; fi
47-
if [ ! -z "$HTTPCHK_HOST" ]; then echo "export HTTPCHK_HOST=\"$HTTPCHK_HOST\"" >> /etc/environment; fi
48-
if [ ! -z "$INTER" ]; then echo "export INTER=\"$INTER\"" >> /etc/environment; fi
49-
if [ ! -z "$LOGGING" ]; then echo "export LOGGING=\"$LOGGING\"" >> /etc/environment; fi
50-
if [ ! -z "$LOG_LEVEL" ]; then echo "export LOG_LEVEL=\"$LOG_LEVEL\"" >> /etc/environment; fi
51-
if [ ! -z "$PROXY_PROTOCOL_ENABLED" ]; then echo "export PROXY_PROTOCOL_ENABLED=\"$PROXY_PROTOCOL_ENABLED\"" >> /etc/environment; fi
52-
if [ ! -z "$RISE" ]; then echo "export RISE=\"$RISE\"" >> /etc/environment; fi
53-
if [ ! -z "$SERVICE_NAMES" ]; then echo "export SERVICE_NAMES=\"$SERVICE_NAMES\"" >> /etc/environment; fi
54-
if [ ! -z "$STATS_AUTH" ]; then echo "export STATS_AUTH=\"$STATS_AUTH\"" >> /etc/environment; fi
55-
if [ ! -z "$STATS_PORT" ]; then echo "export STATS_PORT=\"$STATS_PORT\"" >> /etc/environment; fi
56-
if [ ! -z "$TIMEOUT_CLIENT" ]; then echo "export TIMEOUT_CLIENT=\"$TIMEOUT_CLIENT\"" >> /etc/environment; fi
57-
if [ ! -z "$TIMEOUT_CONNECT" ]; then echo "export TIMEOUT_CONNECT=\"$TIMEOUT_CONNECT\"" >> /etc/environment; fi
58-
if [ ! -z "$TIMEOUT_SERVER" ]; then echo "export TIMEOUT_SERVER=\"$TIMEOUT_SERVER\"" >> /etc/environment; fi
33+
if [ -n "$BACKENDS" ]; then echo "export BACKENDS=\"$BACKENDS\"" >> /etc/environment; fi
34+
if [ -n "$BACKENDS_PORT" ]; then echo "export BACKENDS_PORT=\"$BACKENDS_PORT\"" >> /etc/environment; fi
35+
if [ -n "$BACKENDS_MODE" ]; then echo "export BACKENDS_MODE=\"$BACKENDS_MODE\"" >> /etc/environment; fi
36+
if [ -n "$BACKEND_NAME" ]; then echo "export BACKEND_NAME=\"$BACKEND_NAME\"" >> /etc/environment; fi
37+
if [ -n "$BALANCE" ]; then echo "export BALANCE=\"$BALANCE\"" >> /etc/environment; fi
38+
if [ -n "$COOKIES_ENABLED" ]; then echo "export COOKIES_ENABLED=\"$COOKIES_ENABLED\"" >> /etc/environment; fi
39+
if [ -n "$COOKIES_NAME" ]; then echo "export COOKIES_NAME=\"$COOKIES_NAME\"" >> /etc/environment; fi
40+
if [ -n "$COOKIES_PARAMS" ]; then echo "export COOKIES_PARAMS=\"$COOKIES_PARAMS\"" >> /etc/environment; fi
41+
if [ -n "$DOWN_INTER" ]; then echo "export DOWN_INTER=\"$DOWN_INTER\"" >> /etc/environment; fi
42+
if [ -n "$FALL" ]; then echo "export FALL=\"$FALL\"" >> /etc/environment; fi
43+
if [ -n "$FAST_INTER" ]; then echo "export FAST_INTER=\"$FAST_INTER\"" >> /etc/environment; fi
44+
if [ -n "$FRONTEND_NAME" ]; then echo "export FRONTEND_NAME=\"$FRONTEND_NAME\"" >> /etc/environment; fi
45+
if [ -n "$FRONTEND_PORT" ]; then echo "export FRONTEND_PORT=\"$FRONTEND_PORT\"" >> /etc/environment; fi
46+
if [ -n "$FRONTEND_MODE" ]; then echo "export FRONTEND_MODE=\"$FRONTEND_MODE\"" >> /etc/environment; fi
47+
if [ -n "$HTTPCHK" ]; then echo "export HTTPCHK=\"$HTTPCHK\"" >> /etc/environment; fi
48+
if [ -n "$HTTPCHK_HOST" ]; then echo "export HTTPCHK_HOST=\"$HTTPCHK_HOST\"" >> /etc/environment; fi
49+
if [ -n "$INTER" ]; then echo "export INTER=\"$INTER\"" >> /etc/environment; fi
50+
if [ -n "$LOGGING" ]; then echo "export LOGGING=\"$LOGGING\"" >> /etc/environment; fi
51+
if [ -n "$LOG_LEVEL" ]; then echo "export LOG_LEVEL=\"$LOG_LEVEL\"" >> /etc/environment; fi
52+
if [ -n "$PROXY_PROTOCOL_ENABLED" ]; then echo "export PROXY_PROTOCOL_ENABLED=\"$PROXY_PROTOCOL_ENABLED\"" >> /etc/environment; fi
53+
if [ -n "$RISE" ]; then echo "export RISE=\"$RISE\"" >> /etc/environment; fi
54+
if [ -n "$SERVICE_NAMES" ]; then echo "export SERVICE_NAMES=\"$SERVICE_NAMES\"" >> /etc/environment; fi
55+
if [ -n "$STATS_AUTH" ]; then echo "export STATS_AUTH=\"$STATS_AUTH\"" >> /etc/environment; fi
56+
if [ -n "$STATS_PORT" ]; then echo "export STATS_PORT=\"$STATS_PORT\"" >> /etc/environment; fi
57+
if [ -n "$TIMEOUT_CLIENT" ]; then echo "export TIMEOUT_CLIENT=\"$TIMEOUT_CLIENT\"" >> /etc/environment; fi
58+
if [ -n "$TIMEOUT_CONNECT" ]; then echo "export TIMEOUT_CONNECT=\"$TIMEOUT_CONNECT\"" >> /etc/environment; fi
59+
if [ -n "$TIMEOUT_SERVER" ]; then echo "export TIMEOUT_SERVER=\"$TIMEOUT_SERVER\"" >> /etc/environment; fi
5960
fi
6061

6162

haproxy/src/configure.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
BALANCE = os.environ.get('BALANCE', 'roundrobin')
1616
SERVICE_NAMES = os.environ.get('SERVICE_NAMES', '')
1717
COOKIES_ENABLED = (os.environ.get('COOKIES_ENABLED', 'false').lower() == "true")
18+
COOKIES_NAME = os.environ.get('COOKIES_NAME','SRV_ID')
1819
COOKIES_PARAMS = os.environ.get('COOKIES_PARAMS','')
1920
PROXY_PROTOCOL_ENABLED = (os.environ.get('PROXY_PROTOCOL_ENABLED', 'false').lower() == "true")
2021
STATS_PORT = os.environ.get('STATS_PORT', '1936')
@@ -54,15 +55,15 @@
5455

5556
if COOKIES_ENABLED:
5657
#if we choose to enable session stickiness
57-
#then insert a cookie named SRV_ID to the request:
58+
#then insert a cookie named $COOKIES_NAME(SRV_ID) to the request:
5859
#all responses from HAProxy to the client will contain a Set-Cookie:
5960
#header with a specific value for each backend server as its cookie value.
6061
backend_conf = Template("""
6162
backend $backend
6263
mode $mode
6364
balance $balance
6465
default-server inter $inter fastinter $fastinter downinter $downinter fall $fall rise $rise
65-
cookie SRV_ID insert $cookies_params
66+
cookie $cookies_name insert $cookies_params
6667
""")
6768
cookies = "cookie \\\"@@value@@\\\""
6869
else:
@@ -74,7 +75,7 @@
7475
mode $mode
7576
balance $balance
7677
default-server inter $inter fastinter $fastinter downinter $downinter fall $fall rise $rise
77-
cookie SRV_ID prefix $cookies_params
78+
cookie $cookies_name prefix $cookies_params
7879
""")
7980
cookies = ""
8081

@@ -103,6 +104,7 @@
103104
downinter=DOWN_INTER,
104105
fall=FALL,
105106
rise=RISE,
107+
cookies_name=COOKIES_NAME,
106108
cookies_params=COOKIES_PARAMS
107109
)
108110

0 commit comments

Comments
 (0)