mirror of
https://github.com/b4tman/docker-squid.git
synced 2026-05-26 22:16:12 +03:00
Compare commits
57 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| b8df13a7d6 | |||
| 35953b314c | |||
| 54797967b9 | |||
| 07d9abcbe6 | |||
| 9d1249ebcf | |||
| b29bf01bef | |||
| d3b6a7ea22 | |||
| 4f1b8ed939 | |||
| e783f185b9 | |||
| 4913c55528 | |||
| 5554d165ea | |||
| 3ca2b8926d | |||
| f6b90099d2 | |||
| 24e1818526 | |||
| c74c051f12 | |||
| 2a3391c562 | |||
| 1b1aede330 | |||
| d39bf7f8b6 | |||
| bc1e2c287d | |||
|
8723ca0ca8
|
|||
| 89f53c9af2 | |||
| 883a36790a | |||
| 3ff6520eeb | |||
| 3877c77b6f | |||
| eb2cea4f44 | |||
| 39e61037cb | |||
| 1e431e392b | |||
| c75d1354aa | |||
| 000a827460 | |||
| 8dab59fee5 | |||
| 8669f6e1d5 | |||
| 0978b18b73 | |||
| 63cf1fc739 | |||
| 9aec6fae6a | |||
| 75b290de69 | |||
| 8aab792bc1 | |||
| 7ea8a5793f | |||
|
a3b674e1d5
|
|||
|
2bd55e0a98
|
|||
| fb56ae5164 | |||
| bb4a85b410 | |||
|
abfd29ad78
|
|||
|
16e644983a
|
|||
| 33429ba79f | |||
| 05d3fc71a7 | |||
|
19ecd62b08
|
|||
|
4eb3c96208
|
|||
| c1b8ceee1c | |||
| f504923719 | |||
| 12abc8228d | |||
| 3ceca4d5f2 | |||
| 0e54ff03de | |||
| dd877b801a | |||
| 6db980e029 | |||
| 2420794090 | |||
| 7a1ebcb1ac | |||
| 93898b83e2 |
@@ -0,0 +1 @@
|
|||||||
|
custom: ['https://boosty.to/0xffff']
|
||||||
@@ -21,9 +21,9 @@ env:
|
|||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
test:
|
test:
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Set up QEMU
|
- name: Set up QEMU
|
||||||
uses: docker/setup-qemu-action@v3
|
uses: docker/setup-qemu-action@v3
|
||||||
@@ -39,7 +39,7 @@ jobs:
|
|||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
- name: Cache Docker layers
|
- name: Cache Docker layers
|
||||||
uses: actions/cache@v3.3.2
|
uses: actions/cache@v5.0.3
|
||||||
with:
|
with:
|
||||||
path: /tmp/.buildx-cache
|
path: /tmp/.buildx-cache
|
||||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
@@ -47,7 +47,7 @@ jobs:
|
|||||||
${{ runner.os }}-buildx-
|
${{ runner.os }}-buildx-
|
||||||
|
|
||||||
- name: Build squid image
|
- name: Build squid image
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: false
|
push: false
|
||||||
@@ -65,23 +65,48 @@ jobs:
|
|||||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||||
|
|
||||||
- name: Test image
|
- name: Test image
|
||||||
run: docker compose -f docker-compose.test.yml up --pull never sut
|
run: |
|
||||||
|
set -ex
|
||||||
|
docker compose -f docker-compose.test.yml up --pull never sut --exit-code-from sut
|
||||||
|
docker compose -f docker-compose.test.yml down
|
||||||
|
|
||||||
- name: Build 'ssl-bump' image
|
- name: set base image for 'ssl-bump'
|
||||||
run: |
|
run: |
|
||||||
sed -i "s%FROM b4tman/squid%FROM $TEST_TAG%" ssl-bump/Dockerfile
|
sed -i "s%FROM b4tman/squid%FROM $TEST_TAG%" ssl-bump/Dockerfile
|
||||||
docker build ssl-bump
|
|
||||||
|
|
||||||
|
- name: Build 'ssl-bump' image
|
||||||
|
uses: docker/build-push-action@v6
|
||||||
|
with:
|
||||||
|
context: .
|
||||||
|
push: false
|
||||||
|
load: true
|
||||||
|
tags: ${{ env.TEST_TAG }}-ssl-bump
|
||||||
|
cache-from: type=local,src=/tmp/.buildx-cache
|
||||||
|
cache-to: type=local,dest=/tmp/.buildx-cache-new,mode=max
|
||||||
|
|
||||||
|
# Temp fix
|
||||||
|
# https://github.com/docker/build-push-action/issues/252
|
||||||
|
# https://github.com/moby/buildkit/issues/1896
|
||||||
|
- name: Move cache
|
||||||
|
run: |
|
||||||
|
rm -rf /tmp/.buildx-cache
|
||||||
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||||
|
|
||||||
|
- name: Test 'ssl-bump' image
|
||||||
|
run: |
|
||||||
|
set -ex
|
||||||
|
TEST_TAG="${TEST_TAG}-ssl-bump" docker compose -f docker-compose.test.yml up --pull never sut --exit-code-from sut
|
||||||
|
docker compose -f docker-compose.test.yml down
|
||||||
push:
|
push:
|
||||||
needs: test
|
needs: test
|
||||||
runs-on: ubuntu-20.04
|
runs-on: ubuntu-latest
|
||||||
if: github.event_name != 'pull_request'
|
if: github.event_name != 'pull_request'
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/checkout@v4
|
- uses: actions/checkout@v6
|
||||||
|
|
||||||
- name: Docker meta
|
- name: Docker meta
|
||||||
id: meta
|
id: meta
|
||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
b4tman/squid
|
b4tman/squid
|
||||||
@@ -95,7 +120,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Docker meta (ssl-bump)
|
- name: Docker meta (ssl-bump)
|
||||||
id: meta_ssl_bump
|
id: meta_ssl_bump
|
||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
b4tman/squid
|
b4tman/squid
|
||||||
@@ -110,7 +135,7 @@ jobs:
|
|||||||
|
|
||||||
- name: Docker meta (ssl-bump ghcr)
|
- name: Docker meta (ssl-bump ghcr)
|
||||||
id: meta_ssl_bump_ghcr
|
id: meta_ssl_bump_ghcr
|
||||||
uses: docker/metadata-action@v4
|
uses: docker/metadata-action@v5
|
||||||
with:
|
with:
|
||||||
images: |
|
images: |
|
||||||
ghcr.io/b4tman/squid-ssl-bump
|
ghcr.io/b4tman/squid-ssl-bump
|
||||||
@@ -128,7 +153,7 @@ jobs:
|
|||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
- name: Cache Docker layers
|
- name: Cache Docker layers
|
||||||
uses: actions/cache@v3.3.2
|
uses: actions/cache@v5.0.3
|
||||||
with:
|
with:
|
||||||
path: /tmp/.buildx-cache
|
path: /tmp/.buildx-cache
|
||||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||||
@@ -149,7 +174,7 @@ jobs:
|
|||||||
password: ${{ secrets.CR_PAT }}
|
password: ${{ secrets.CR_PAT }}
|
||||||
|
|
||||||
- name: Build squid image
|
- name: Build squid image
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: .
|
context: .
|
||||||
push: true
|
push: true
|
||||||
@@ -168,7 +193,7 @@ jobs:
|
|||||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||||
|
|
||||||
- name: Build 'ssl-bump' image
|
- name: Build 'ssl-bump' image
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: ssl-bump
|
context: ssl-bump
|
||||||
push: true
|
push: true
|
||||||
@@ -188,7 +213,7 @@ jobs:
|
|||||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||||
|
|
||||||
- name: Build 'ssl-bump' image for ghcr
|
- name: Build 'ssl-bump' image for ghcr
|
||||||
uses: docker/build-push-action@v4
|
uses: docker/build-push-action@v6
|
||||||
with:
|
with:
|
||||||
context: ssl-bump
|
context: ssl-bump
|
||||||
push: true
|
push: true
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ jobs:
|
|||||||
pull-requests: write
|
pull-requests: write
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
- uses: actions/stale@v8
|
- uses: actions/stale@v10
|
||||||
with:
|
with:
|
||||||
days-before-stale: 182
|
days-before-stale: 182
|
||||||
days-before-close: 7
|
days-before-close: 7
|
||||||
|
|||||||
+15
-18
@@ -1,6 +1,6 @@
|
|||||||
FROM alpine:3.18.4 as build
|
FROM alpine:3.23.3 AS build
|
||||||
|
|
||||||
ARG SQUID_VER=6.4
|
ARG SQUID_VER=7.4
|
||||||
|
|
||||||
RUN set -x && \
|
RUN set -x && \
|
||||||
apk add --no-cache \
|
apk add --no-cache \
|
||||||
@@ -24,8 +24,8 @@ RUN set -x && \
|
|||||||
WORKDIR /tmp/build
|
WORKDIR /tmp/build
|
||||||
|
|
||||||
RUN set -x && \
|
RUN set -x && \
|
||||||
curl -SsL http://www.squid-cache.org/Versions/v${SQUID_VER%%.*}/squid-${SQUID_VER}.tar.gz -o squid-${SQUID_VER}.tar.gz && \
|
curl -fSsL "https://github.com/squid-cache/squid/releases/download/SQUID_${SQUID_VER//./_}/squid-${SQUID_VER}.tar.gz" -o squid-${SQUID_VER}.tar.gz && \
|
||||||
curl -SsL http://www.squid-cache.org/Versions/v${SQUID_VER%%.*}/squid-${SQUID_VER}.tar.gz.asc -o squid-${SQUID_VER}.tar.gz.asc
|
curl -fSsL "https://github.com/squid-cache/squid/releases/download/SQUID_${SQUID_VER//./_}/squid-${SQUID_VER}.tar.gz.asc" -o squid-${SQUID_VER}.tar.gz.asc
|
||||||
|
|
||||||
COPY squid-keys.asc /tmp/build
|
COPY squid-keys.asc /tmp/build
|
||||||
|
|
||||||
@@ -98,18 +98,15 @@ RUN set -x && \
|
|||||||
make -j $nproc && \
|
make -j $nproc && \
|
||||||
make install
|
make install
|
||||||
|
|
||||||
WORKDIR /tmp/build/tools/squidclient
|
|
||||||
RUN make && make install-strip
|
|
||||||
|
|
||||||
RUN sed -i '1s;^;include /etc/squid/conf.d/*.conf\n;' /etc/squid/squid.conf && \
|
RUN sed -i '1s;^;include /etc/squid/conf.d/*.conf\n;' /etc/squid/squid.conf && \
|
||||||
echo 'include /etc/squid/conf.d.tail/*.conf' >> /etc/squid/squid.conf
|
echo 'include /etc/squid/conf.d.tail/*.conf' >> /etc/squid/squid.conf
|
||||||
|
|
||||||
# --- --- --- --- --- --- --- --- ---
|
# --- --- --- --- --- --- --- --- ---
|
||||||
|
|
||||||
FROM alpine:3.18.4
|
FROM alpine:3.23.3
|
||||||
|
|
||||||
ENV SQUID_CONFIG_FILE /etc/squid/squid.conf
|
ENV SQUID_CONFIG_FILE=/etc/squid/squid.conf
|
||||||
ENV TZ Europe/Moscow
|
ENV TZ=Europe/Moscow
|
||||||
|
|
||||||
RUN set -x && \
|
RUN set -x && \
|
||||||
deluser squid 2>/dev/null; delgroup squid 2>/dev/null; \
|
deluser squid 2>/dev/null; delgroup squid 2>/dev/null; \
|
||||||
@@ -119,13 +116,17 @@ RUN apk add --no-cache \
|
|||||||
libstdc++ \
|
libstdc++ \
|
||||||
heimdal-libs \
|
heimdal-libs \
|
||||||
libcap \
|
libcap \
|
||||||
libltdl
|
libltdl \
|
||||||
|
apache2-utils \
|
||||||
|
curl \
|
||||||
|
tzdata
|
||||||
|
|
||||||
COPY --from=build /etc/squid/ /etc/squid/
|
COPY --from=build /etc/squid/ /etc/squid/
|
||||||
COPY --from=build /usr/lib/squid/ /usr/lib/squid/
|
COPY --from=build /usr/lib/squid/ /usr/lib/squid/
|
||||||
COPY --from=build /usr/share/squid/ /usr/share/squid/
|
COPY --from=build /usr/share/squid/ /usr/share/squid/
|
||||||
COPY --from=build /usr/sbin/squid /usr/sbin/squid
|
COPY --from=build /usr/sbin/squid /usr/sbin/squid
|
||||||
COPY --from=build /usr/bin/squidclient /usr/bin/squidclient
|
|
||||||
|
COPY --chmod=755 run.sh /
|
||||||
|
|
||||||
RUN install -d -o squid -g squid \
|
RUN install -d -o squid -g squid \
|
||||||
/var/cache/squid \
|
/var/cache/squid \
|
||||||
@@ -136,16 +137,12 @@ RUN install -d -o squid -g squid \
|
|||||||
/etc/squid/conf.d \
|
/etc/squid/conf.d \
|
||||||
/etc/squid/conf.d.tail && \
|
/etc/squid/conf.d.tail && \
|
||||||
touch /etc/squid/conf.d/placeholder.conf
|
touch /etc/squid/conf.d/placeholder.conf
|
||||||
|
COPY localnet.conf /etc/squid/conf.d/
|
||||||
COPY squid-log.conf /etc/squid/conf.d.tail/
|
COPY squid-log.conf /etc/squid/conf.d.tail/
|
||||||
|
|
||||||
RUN set -x && \
|
|
||||||
apk add --no-cache --virtual .tz alpine-conf tzdata && \
|
|
||||||
/sbin/setup-timezone -z $TZ && \
|
|
||||||
apk del .tz
|
|
||||||
|
|
||||||
VOLUME ["/var/cache/squid"]
|
VOLUME ["/var/cache/squid"]
|
||||||
EXPOSE 3128/tcp
|
EXPOSE 3128/tcp
|
||||||
|
|
||||||
USER squid
|
USER squid
|
||||||
|
|
||||||
CMD ["sh", "-c", "rm -f /var/run/squid/squid.pid ; /usr/sbin/squid -f ${SQUID_CONFIG_FILE} --foreground -z && exec /usr/sbin/squid -f ${SQUID_CONFIG_FILE} --foreground -YCd 1"]
|
CMD ["/run.sh"]
|
||||||
|
|||||||
@@ -30,9 +30,21 @@ docker-compose up
|
|||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
|
|
||||||
|
By default, the image now includes a local network allow-list (`/etc/squid/conf.d/localnet.conf`) so clients from RFC1918/RFC4193 ranges can connect without mounting an extra ACL file.
|
||||||
|
|
||||||
|
The image also includes `apache2-utils`, so you can generate and manage `htpasswd` files directly in the container for basic authentication setups.
|
||||||
|
|
||||||
|
|
||||||
## Environment variables:
|
## Environment variables:
|
||||||
|
|
||||||
- **SQUID_CONFIG_FILE**: Specify the configuration file for squid. Defaults to `/etc/squid/squid.conf`.
|
- **SQUID_CONFIG_FILE**: Specify the configuration file for squid. Defaults to `/etc/squid/squid.conf`.
|
||||||
|
- **TZ**: Override the container timezone (for example, `Europe/Berlin`).
|
||||||
|
|
||||||
|
You can configure Squid in multiple ways:
|
||||||
|
|
||||||
|
- Replace the main configuration file by overriding `SQUID_CONFIG_FILE`.
|
||||||
|
- Add configuration snippets to `/etc/squid/conf.d`: all `*.conf` files from this directory are included at the **beginning** of the default configuration.
|
||||||
|
- Add configuration snippets to `/etc/squid/conf.d.tail`: all `*.conf` files from this directory are included at the **end** of the default configuration.
|
||||||
|
|
||||||
## Example:
|
## Example:
|
||||||
|
|
||||||
|
|||||||
@@ -1,9 +1,8 @@
|
|||||||
version: '2.3'
|
|
||||||
services:
|
services:
|
||||||
proxy:
|
proxy:
|
||||||
image: "${TEST_TAG}"
|
image: "${TEST_TAG}"
|
||||||
healthcheck:
|
healthcheck:
|
||||||
test: ["CMD", "sh", "-exc", "squidclient -T 3 mgr:info 2> /dev/null | grep -qF '200 OK'"]
|
test: ["CMD", "sh", "-exc", "curl -s -o /dev/null --max-time 3 -w '%{http_code}' 'http://127.0.0.1:3128/squid-internal-mgr/info' 2> /dev/null | grep -qF '200'"]
|
||||||
interval: 5s
|
interval: 5s
|
||||||
timeout: 3s
|
timeout: 3s
|
||||||
retries: 5
|
retries: 5
|
||||||
@@ -14,5 +13,4 @@ services:
|
|||||||
- proxy
|
- proxy
|
||||||
depends_on:
|
depends_on:
|
||||||
- proxy
|
- proxy
|
||||||
command: sh -exc "sleep 10 && squidclient -h proxy -T 3 'https://postman-echo.com/get?squidtest=ok' 2> /dev/null | grep -qF '200 OK'"
|
command: sh -exc "sleep 10 && curl --proxy='http://proxy:3128' -s -o /dev/null --max-time 3 -w '%{http_code}' 'https://postman-echo.com/get?squidtest=ok' 2> /dev/null | grep -qF '200'"
|
||||||
|
|
||||||
|
|||||||
@@ -1,4 +1,3 @@
|
|||||||
version: '2'
|
|
||||||
services:
|
services:
|
||||||
squid:
|
squid:
|
||||||
image: 'b4tman/squid'
|
image: 'b4tman/squid'
|
||||||
|
|||||||
@@ -0,0 +1,11 @@
|
|||||||
|
acl localnet1 src 0.0.0.1-0.255.255.255 # RFC 1122 "this" network (LAN)
|
||||||
|
acl localnet1 src 10.0.0.0/8 # RFC 1918 local private network (LAN)
|
||||||
|
acl localnet1 src 100.64.0.0/10 # RFC 6598 shared address space (CGN)
|
||||||
|
acl localnet1 src 169.254.0.0/16 # RFC 3927 link-local (directly plugged) machines
|
||||||
|
acl localnet1 src 172.16.0.0/12 # RFC 1918 local private network (LAN)
|
||||||
|
acl localnet1 src 192.168.0.0/16 # RFC 1918 local private network (LAN)
|
||||||
|
acl localnet1 src fc00::/7 # RFC 4193 local private network range
|
||||||
|
acl localnet1 src fe80::/10 # RFC 4291 link-local (directly plugged) machines
|
||||||
|
|
||||||
|
http_access allow localnet1
|
||||||
|
http_access allow localhost manager
|
||||||
@@ -0,0 +1,14 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
# force remove pid
|
||||||
|
if [ -e /var/run/squid/squid.pid ]; then
|
||||||
|
rm -f /var/run/squid/squid.pid
|
||||||
|
fi
|
||||||
|
|
||||||
|
# init cache
|
||||||
|
/usr/sbin/squid -f "${SQUID_CONFIG_FILE}" --foreground -z
|
||||||
|
|
||||||
|
# run squid
|
||||||
|
exec /usr/sbin/squid -f "${SQUID_CONFIG_FILE}" --foreground -YCd 1
|
||||||
Binary file not shown.
+6
-1
@@ -1,4 +1,9 @@
|
|||||||
FROM b4tman/squid
|
FROM b4tman/squid
|
||||||
|
|
||||||
|
COPY run.sh /
|
||||||
USER root
|
USER root
|
||||||
CMD ["sh", "-c", "(test -d /var/cache/squid/ssl_db || /usr/lib/squid/security_file_certgen -c -s /var/cache/squid/ssl_db -M 4MB) && /usr/sbin/squid -f ${SQUID_CONFIG_FILE} --foreground -z && exec /usr/sbin/squid -f ${SQUID_CONFIG_FILE} --foreground -YCd 1"]
|
RUN chmod 755 /run.sh
|
||||||
|
|
||||||
|
USER squid
|
||||||
|
|
||||||
|
CMD ["/run.sh"]
|
||||||
|
|||||||
@@ -0,0 +1,19 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -x
|
||||||
|
|
||||||
|
# init ssl_db
|
||||||
|
if [ ! -d /var/cache/squid/ssl_db ]; then
|
||||||
|
/usr/lib/squid/security_file_certgen -c -s /var/cache/squid/ssl_db -M 4MB
|
||||||
|
fi
|
||||||
|
|
||||||
|
# force remove pid
|
||||||
|
if [ -e /var/run/squid/squid.pid ]; then
|
||||||
|
rm -f /var/run/squid/squid.pid
|
||||||
|
fi
|
||||||
|
|
||||||
|
# init cache
|
||||||
|
/usr/sbin/squid -f "${SQUID_CONFIG_FILE}" --foreground -z
|
||||||
|
|
||||||
|
# run squid
|
||||||
|
exec /usr/sbin/squid -f "${SQUID_CONFIG_FILE}" --foreground -YCd 1
|
||||||
Reference in New Issue
Block a user