Skip to content

Commit 4bde89b

Browse files
authored
Merge pull request #27 from linuxserver/haproxy
Switch back to HAProxy
2 parents 9df15b1 + 5a46a71 commit 4bde89b

15 files changed

+98
-422
lines changed

.github/workflows/external_trigger.yml

+2-2
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ jobs:
2727
echo "> External trigger running off of main branch. To disable this trigger, add \`socket-proxy_main\` into the Github organizational variable \`SKIP_EXTERNAL_TRIGGER\`." >> $GITHUB_STEP_SUMMARY
2828
printf "\n## Retrieving external version\n\n" >> $GITHUB_STEP_SUMMARY
2929
EXT_RELEASE=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.21/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
30-
&& awk '/^P:'"nginx"'$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://')
30+
&& awk '/^P:'"haproxy"'$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://')
3131
echo "Type is \`alpine_repo\`" >> $GITHUB_STEP_SUMMARY
3232
if grep -q "^socket-proxy_main_${EXT_RELEASE}" <<< "${SKIP_EXTERNAL_TRIGGER}"; then
3333
echo "> [!WARNING]" >> $GITHUB_STEP_SUMMARY
@@ -104,7 +104,7 @@ jobs:
104104
if [ "${EXT_RELEASE}" == "${IMAGE_VERSION}" ]; then
105105
echo "Version \`${EXT_RELEASE}\` already pushed, exiting" >> $GITHUB_STEP_SUMMARY
106106
exit 0
107-
elif [[ $(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.21/main/aarch64/APKINDEX.tar.gz" | tar -xz -C /tmp && awk '/^P:'"nginx"'$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://') != "${EXT_RELEASE}" ]]; then
107+
elif [[ $(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.21/main/aarch64/APKINDEX.tar.gz" | tar -xz -C /tmp && awk '/^P:'"haproxy"'$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://') != "${EXT_RELEASE}" ]]; then
108108
echo "New version \`${EXT_RELEASE}\` found; but not all arch repos updated yet; exiting" >> $GITHUB_STEP_SUMMARY
109109
FAILURE_REASON="New version ${EXT_RELEASE} for socket-proxy tag latest is detected, however not all arch repos are updated yet. Will try again later."
110110
curl -X POST -H "Content-Type: application/json" --data '{"avatar_url": "https://cdn.discordapp.com/avatars/354986384542662657/df91181b3f1cf0ef1592fbe18e0962d7.png","embeds": [{"color": 9802903,

Dockerfile

+11-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FROM docker.io/alpine:3.21
55
# set version label
66
ARG BUILD_DATE
77
ARG VERSION
8-
ARG NGINX_VERSION
8+
ARG HAPROXY_VERSION
99
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
1010
LABEL maintainer="thespad"
1111

@@ -14,18 +14,19 @@ RUN \
1414
echo "**** install build packages ****" && \
1515
apk add --no-cache \
1616
alpine-release \
17-
bash \
18-
curl \
19-
envsubst && \
20-
if [ -z ${NGINX_VERSION+x} ]; then \
21-
NGINX_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.21/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
22-
&& awk '/^P:nginx$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://'); \
17+
curl && \
18+
if [ -z ${HAPROXY_VERSION+x} ]; then \
19+
HAPROXY_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.21/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
20+
&& awk '/^P:haproxy$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://'); \
2321
fi && \
2422
apk add --no-cache \
25-
nginx==${NGINX_VERSION} && \
23+
haproxy==${HAPROXY_VERSION} && \
2624
printf "Linuxserver.io version: ${VERSION}\nBuild-date: ${BUILD_DATE}" > /build_version && \
27-
rm -f /etc/nginx/conf.d/stream.conf && \
28-
rm -f /etc/nginx/http.d/default.conf
25+
apk del --no-cache \
26+
curl && \
27+
rm -rf \
28+
/etc/haproxy \
29+
/tmp/*
2930

3031
ENV ALLOW_RESTARTS=0 \
3132
ALLOW_STOP=0 \
@@ -58,6 +59,4 @@ ENV ALLOW_RESTARTS=0 \
5859
# add local files
5960
COPY root/ /
6061

61-
EXPOSE 2375
62-
6362
ENTRYPOINT ["/docker-entrypoint.sh"]

Dockerfile.aarch64

+11-12
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ FROM docker.io/alpine:3.21
55
# set version label
66
ARG BUILD_DATE
77
ARG VERSION
8-
ARG NGINX_VERSION
8+
ARG HAPROXY_VERSION
99
LABEL build_version="Linuxserver.io version:- ${VERSION} Build-date:- ${BUILD_DATE}"
1010
LABEL maintainer="thespad"
1111

@@ -14,18 +14,19 @@ RUN \
1414
echo "**** install build packages ****" && \
1515
apk add --no-cache \
1616
alpine-release \
17-
bash \
18-
curl \
19-
envsubst && \
20-
if [ -z ${NGINX_VERSION+x} ]; then \
21-
NGINX_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.21/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
22-
&& awk '/^P:nginx$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://'); \
17+
curl && \
18+
if [ -z ${HAPROXY_VERSION+x} ]; then \
19+
HAPROXY_VERSION=$(curl -sL "http://dl-cdn.alpinelinux.org/alpine/v3.21/main/x86_64/APKINDEX.tar.gz" | tar -xz -C /tmp \
20+
&& awk '/^P:haproxy$/,/V:/' /tmp/APKINDEX | sed -n 2p | sed 's/^V://'); \
2321
fi && \
2422
apk add --no-cache \
25-
nginx==${NGINX_VERSION} && \
23+
haproxy==${HAPROXY_VERSION} && \
2624
printf "Linuxserver.io version: ${VERSION}\nBuild-date: ${BUILD_DATE}" > /build_version && \
27-
rm -f /etc/nginx/conf.d/stream.conf && \
28-
rm -f /etc/nginx/http.d/default.conf
25+
apk del --no-cache \
26+
curl && \
27+
rm -rf \
28+
/etc/haproxy \
29+
/tmp/*
2930

3031
ENV ALLOW_RESTARTS=0 \
3132
ALLOW_STOP=0 \
@@ -58,6 +59,4 @@ ENV ALLOW_RESTARTS=0 \
5859
# add local files
5960
COPY root/ /
6061

61-
EXPOSE 2375
62-
6362
ENTRYPOINT ["/docker-entrypoint.sh"]

Jenkinsfile

+2-2
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ pipeline {
1919
DOCKERHUB_TOKEN=credentials('docker-hub-ci-pat')
2020
QUAYIO_API_TOKEN=credentials('quayio-repo-api-token')
2121
GIT_SIGNING_KEY=credentials('484fbca6-9a4f-455e-b9e3-97ac98785f5f')
22-
BUILD_VERSION_ARG = 'NGINX_VERSION'
22+
BUILD_VERSION_ARG = 'HAPROXY_VERSION'
2323
LS_USER = 'linuxserver'
2424
LS_REPO = 'docker-socket-proxy'
2525
CONTAINER_NAME = 'socket-proxy'
@@ -28,7 +28,7 @@ pipeline {
2828
PR_DOCKERHUB_IMAGE = 'lspipepr/socket-proxy'
2929
DIST_IMAGE = 'alpine'
3030
DIST_REPO = 'http://dl-cdn.alpinelinux.org/alpine/v3.21/main/'
31-
DIST_REPO_PACKAGES = 'nginx'
31+
DIST_REPO_PACKAGES = 'haproxy'
3232
MULTIARCH='true'
3333
CI='true'
3434
CI_WEB='false'

README.md

+3-5
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ The architectures supported by this image are:
5252

5353
## Application Setup
5454

55-
This container is based on [https://github.com/Tecnativa/docker-socket-proxy](https://github.com/Tecnativa/docker-socket-proxy) and as such does not follow our usual container conventions. It *does not* support mods or custom scripts/services, or running as a user other than root (or the docker user in a rootless environment). It is designed to act as a drop-in replacement for the Tecnativa container.
55+
This container is conceptually based on [https://github.com/Tecnativa/docker-socket-proxy](https://github.com/Tecnativa/docker-socket-proxy) and as such does not follow our usual container conventions. It *does not* support mods or custom scripts/services, or running as a user other than root (or the docker user in a rootless environment). It is designed to act as a drop-in replacement for the Tecnativa container.
5656

5757
The container should be run on the same docker network as the service(s) using it. Most containers that would normally connect to a mounted docker.sock can have their endpoint overridden using the `DOCKER_HOST` environment variable if they do not offer the option in their configuration; it should typically be pointed to `tcp://socket-proxy:2375`.
5858

@@ -100,7 +100,6 @@ services:
100100
- PING=1 #optional
101101
- PLUGINS=0 #optional
102102
- POST=0 #optional
103-
- PROXY_READ_TIMEOUT=240 #optional
104103
- SECRETS=0 #optional
105104
- SERVICES=0 #optional
106105
- SESSION=0 #optional
@@ -141,7 +140,6 @@ docker run -d \
141140
-e PING=1 `#optional` \
142141
-e PLUGINS=0 `#optional` \
143142
-e POST=0 `#optional` \
144-
-e PROXY_READ_TIMEOUT=240 `#optional` \
145143
-e SECRETS=0 `#optional` \
146144
-e SERVICES=0 `#optional` \
147145
-e SESSION=0 `#optional` \
@@ -172,7 +170,7 @@ Containers are configured using parameters passed at runtime (such as those abov
172170
| `-e CONFIGS=0` | `/configs` |
173171
| `-e CONTAINERS=0` | `/containers` |
174172
| `-e DISTRIBUTION=0` | `/distribution` |
175-
| `-e DISABLE_IPV6=0` | Set to `1` to prevent nginx binding to the IPv6 interface for legacy system that cannot support IPv6. |
173+
| `-e DISABLE_IPV6=0` | Set to `1` to prevent binding to the IPv6 interface for legacy systems that cannot support IPv6. |
176174
| `-e EVENTS=1` | `/events` |
177175
| `-e EXEC=0` | `/exec` & `/containers/{id}/exec` |
178176
| `-e IMAGES=0` | `/images` |
@@ -182,7 +180,6 @@ Containers are configured using parameters passed at runtime (such as those abov
182180
| `-e PING=1` | `/_ping` |
183181
| `-e PLUGINS=0` | `/plugins` |
184182
| `-e POST=0` | When set to `0`, only `GET` and `HEAD` operations are allowed, making API access read-only. |
185-
| `-e PROXY_READ_TIMEOUT=240` | Connection timeout when no data is being sent. Useful for tailing quiet containers. Accepts values in s/m/h/d/w, no suffix assumes s. |
186183
| `-e SECRETS=0` | `/secrets` |
187184
| `-e SERVICES=0` | `/services` |
188185
| `-e SESSION=0` | `/session` |
@@ -315,6 +312,7 @@ Once registered you can define the dockerfile to use with `-f Dockerfile.aarch64
315312

316313
## Versions
317314

315+
* **06.04.25:** - Switch back to haproxy for better handling of `docker exec` connection hijacking.
318316
* **02.01.25:** - Support custom read timeout values.
319317
* **05.12.24:** - Rebase to Alpine 3.21.
320318
* **26.08.24:** - Change `ALLOW_START`, `ALLOW_STOP`, and `ALLOW_RESTARTS` to work even with `POST=0`.

jenkins-vars.yml

+2-4
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,8 @@ external_type: alpine_repo
66
release_type: stable
77
release_tag: latest
88
ls_branch: main
9-
image_sbom: true
10-
image_provenance: true
119
repo_vars:
12-
- BUILD_VERSION_ARG = 'NGINX_VERSION'
10+
- BUILD_VERSION_ARG = 'HAPROXY_VERSION'
1311
- LS_USER = 'linuxserver'
1412
- LS_REPO = 'docker-socket-proxy'
1513
- CONTAINER_NAME = 'socket-proxy'
@@ -18,7 +16,7 @@ repo_vars:
1816
- PR_DOCKERHUB_IMAGE = 'lspipepr/socket-proxy'
1917
- DIST_IMAGE = 'alpine'
2018
- DIST_REPO = 'http://dl-cdn.alpinelinux.org/alpine/v3.21/main/'
21-
- DIST_REPO_PACKAGES = 'nginx'
19+
- DIST_REPO_PACKAGES = 'haproxy'
2220
- MULTIARCH='true'
2321
- CI='true'
2422
- CI_WEB='false'

readme-vars.yml

+3-5
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ full_custom_readme: |
5959
6060
## Application Setup
6161
62-
This container is based on [https://github.com/Tecnativa/docker-socket-proxy](https://github.com/Tecnativa/docker-socket-proxy) and as such does not follow our usual container conventions. It *does not* support mods or custom scripts/services, or running as a user other than root (or the docker user in a rootless environment). It is designed to act as a drop-in replacement for the Tecnativa container.
62+
This container is conceptually based on [https://github.com/Tecnativa/docker-socket-proxy](https://github.com/Tecnativa/docker-socket-proxy) and as such does not follow our usual container conventions. It *does not* support mods or custom scripts/services, or running as a user other than root (or the docker user in a rootless environment). It is designed to act as a drop-in replacement for the Tecnativa container.
6363
6464
The container should be run on the same docker network as the service(s) using it. Most containers that would normally connect to a mounted docker.sock can have their endpoint overridden using the `DOCKER_HOST` environment variable if they do not offer the option in their configuration; it should typically be pointed to `tcp://socket-proxy:2375`.
6565
@@ -107,7 +107,6 @@ full_custom_readme: |
107107
- PING=1 #optional
108108
- PLUGINS=0 #optional
109109
- POST=0 #optional
110-
- PROXY_READ_TIMEOUT=240 #optional
111110
- SECRETS=0 #optional
112111
- SERVICES=0 #optional
113112
- SESSION=0 #optional
@@ -148,7 +147,6 @@ full_custom_readme: |
148147
-e PING=1 `#optional` \
149148
-e PLUGINS=0 `#optional` \
150149
-e POST=0 `#optional` \
151-
-e PROXY_READ_TIMEOUT=240 `#optional` \
152150
-e SECRETS=0 `#optional` \
153151
-e SERVICES=0 `#optional` \
154152
-e SESSION=0 `#optional` \
@@ -179,7 +177,7 @@ full_custom_readme: |
179177
| `-e CONFIGS=0` | `/configs` |
180178
| `-e CONTAINERS=0` | `/containers` |
181179
| `-e DISTRIBUTION=0` | `/distribution` |
182-
| `-e DISABLE_IPV6=0` | Set to `1` to prevent nginx binding to the IPv6 interface for legacy system that cannot support IPv6. |
180+
| `-e DISABLE_IPV6=0` | Set to `1` to prevent binding to the IPv6 interface for legacy systems that cannot support IPv6. |
183181
| `-e EVENTS=1` | `/events` |
184182
| `-e EXEC=0` | `/exec` & `/containers/{id}/exec` |
185183
| `-e IMAGES=0` | `/images` |
@@ -189,7 +187,6 @@ full_custom_readme: |
189187
| `-e PING=1` | `/_ping` |
190188
| `-e PLUGINS=0` | `/plugins` |
191189
| `-e POST=0` | When set to `0`, only `GET` and `HEAD` operations are allowed, making API access read-only. |
192-
| `-e PROXY_READ_TIMEOUT=240` | Connection timeout when no data is being sent. Useful for tailing quiet containers. Accepts values in s/m/h/d/w, no suffix assumes s. |
193190
| `-e SECRETS=0` | `/secrets` |
194191
| `-e SERVICES=0` | `/services` |
195192
| `-e SESSION=0` | `/session` |
@@ -322,6 +319,7 @@ full_custom_readme: |
322319
323320
## Versions
324321
322+
* **06.04.25:** - Switch back to haproxy for better handling of `docker exec` connection hijacking.
325323
* **02.01.25:** - Support custom read timeout values.
326324
* **05.12.24:** - Rebase to Alpine 3.21.
327325
* **26.08.24:** - Change `ALLOW_START`, `ALLOW_STOP`, and `ALLOW_RESTARTS` to work even with `POST=0`.

root/docker-entrypoint.sh

+8-12
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,14 @@
1-
#!/bin/bash
1+
#!/bin/sh
22

3-
export PROXY_READ_TIMEOUT=${PROXY_READ_TIMEOUT:-240}
3+
mkdir -p /run/haproxy
44

5-
if [[ $POST == 1 ]] && [[ $DISABLE_IPV6 == 1 ]]; then
6-
envsubst "$(printf '${%s} ' $(bash -c "compgen -A variable"))" < /templates/default_post_ipv4.template > /run/default.conf
7-
elif [[ $POST == 0 ]] && [[ $DISABLE_IPV6 == 1 ]]; then
8-
envsubst "$(printf '${%s} ' $(bash -c "compgen -A variable"))" < /templates/default_nopost_ipv4.template > /run/default.conf
9-
elif [[ $POST == 1 ]]; then
10-
envsubst "$(printf '${%s} ' $(bash -c "compgen -A variable"))" < /templates/default_post.template > /run/default.conf
5+
if [ "${DISABLE_IPV6}" = 1 ]; then
6+
BIND_PROTO=":2375"
117
else
12-
envsubst "$(printf '${%s} ' $(bash -c "compgen -A variable"))" < /templates/default_nopost.template > /run/default.conf
8+
BIND_PROTO="[::]:2375 v4v6"
139
fi
1410

15-
mkdir /run/nginx-tmp
11+
sed "s/@@BIND_PROTO@@/${BIND_PROTO}/g" /templates/haproxy.cfg > /run/haproxy/haproxy.cfg
1612

1713
echo '
1814
───────────────────────────────────────
@@ -32,7 +28,7 @@ To support LSIO projects visit:
3228
https://www.linuxserver.io/donate/
3329
3430
───────────────────────────────────────'
35-
if [[ -f /build_version ]]; then
31+
if [ -f /build_version ]; then
3632
cat /build_version
3733
echo '
3834
───────────────────────────────────────
@@ -41,4 +37,4 @@ fi
4137

4238
echo "[ls.io-init] done."
4339

44-
exec /usr/sbin/nginx -e stderr
40+
exec /usr/sbin/haproxy -f /run/haproxy/haproxy.cfg -W -db

root/etc/nginx/nginx.conf

-76
This file was deleted.

root/etc/nginx/proxy.conf

-34
This file was deleted.

0 commit comments

Comments
 (0)