mirror of
https://github.com/b4tman/docker-squid.git
synced 2026-05-26 14:06:12 +03:00
Compare commits
2 Commits
38b02d14fd
..
v6.0.2
| Author | SHA1 | Date | |
|---|---|---|---|
|
09aba63183
|
|||
|
358cbfef87
|
@@ -1 +0,0 @@
|
||||
custom: ['https://dalink.to/b4tman1', 'https://boosty.to/0xffff']
|
||||
@@ -4,8 +4,8 @@ on:
|
||||
push:
|
||||
# Publish `master` as Docker `latest` image.
|
||||
branches:
|
||||
- master
|
||||
- v5
|
||||
- master
|
||||
- v6
|
||||
|
||||
# Publish `v1.2.3` tags as releases.
|
||||
tags:
|
||||
@@ -21,25 +21,25 @@ env:
|
||||
|
||||
jobs:
|
||||
test:
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-20.04
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v4
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Login to DockerHub
|
||||
if: github.event_name != 'pull_request'
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: b4tman
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v5.0.4
|
||||
uses: actions/cache@v3.3.1
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
@@ -47,7 +47,7 @@ jobs:
|
||||
${{ runner.os }}-buildx-
|
||||
|
||||
- name: Build squid image
|
||||
uses: docker/build-push-action@v7
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
push: false
|
||||
@@ -65,48 +65,23 @@ jobs:
|
||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||
|
||||
- name: Test image
|
||||
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
|
||||
run: docker compose -f docker-compose.test.yml up --pull never sut
|
||||
|
||||
- name: set base image for 'ssl-bump'
|
||||
- name: Build 'ssl-bump' image
|
||||
run: |
|
||||
sed -i "s%FROM b4tman/squid%FROM $TEST_TAG%" ssl-bump/Dockerfile
|
||||
|
||||
- name: Build 'ssl-bump' image
|
||||
uses: docker/build-push-action@v7
|
||||
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
|
||||
docker build ssl-bump
|
||||
|
||||
# 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:
|
||||
needs: test
|
||||
runs-on: ubuntu-latest
|
||||
runs-on: ubuntu-20.04
|
||||
if: github.event_name != 'pull_request'
|
||||
steps:
|
||||
- uses: actions/checkout@v6
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Docker meta
|
||||
id: meta
|
||||
uses: docker/metadata-action@v6
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: |
|
||||
b4tman/squid
|
||||
@@ -120,7 +95,7 @@ jobs:
|
||||
|
||||
- name: Docker meta (ssl-bump)
|
||||
id: meta_ssl_bump
|
||||
uses: docker/metadata-action@v6
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: |
|
||||
b4tman/squid
|
||||
@@ -135,7 +110,7 @@ jobs:
|
||||
|
||||
- name: Docker meta (ssl-bump ghcr)
|
||||
id: meta_ssl_bump_ghcr
|
||||
uses: docker/metadata-action@v6
|
||||
uses: docker/metadata-action@v4
|
||||
with:
|
||||
images: |
|
||||
ghcr.io/b4tman/squid-ssl-bump
|
||||
@@ -147,13 +122,13 @@ jobs:
|
||||
type=semver,pattern={{major}}.{{minor}}
|
||||
|
||||
- name: Set up QEMU
|
||||
uses: docker/setup-qemu-action@v4
|
||||
uses: docker/setup-qemu-action@v2
|
||||
|
||||
- name: Set up Docker Buildx
|
||||
uses: docker/setup-buildx-action@v4
|
||||
uses: docker/setup-buildx-action@v2
|
||||
|
||||
- name: Cache Docker layers
|
||||
uses: actions/cache@v5.0.4
|
||||
uses: actions/cache@v3.3.1
|
||||
with:
|
||||
path: /tmp/.buildx-cache
|
||||
key: ${{ runner.os }}-buildx-${{ github.sha }}
|
||||
@@ -161,20 +136,20 @@ jobs:
|
||||
${{ runner.os }}-buildx-
|
||||
|
||||
- name: Login to DockerHub
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
username: b4tman
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
- name: Login to GHCR
|
||||
uses: docker/login-action@v3
|
||||
uses: docker/login-action@v2
|
||||
with:
|
||||
registry: ghcr.io
|
||||
username: ${{ github.repository_owner }}
|
||||
password: ${{ secrets.CR_PAT }}
|
||||
|
||||
- name: Build squid image
|
||||
uses: docker/build-push-action@v7
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: .
|
||||
push: true
|
||||
@@ -193,7 +168,7 @@ jobs:
|
||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||
|
||||
- name: Build 'ssl-bump' image
|
||||
uses: docker/build-push-action@v7
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: ssl-bump
|
||||
push: true
|
||||
@@ -213,7 +188,7 @@ jobs:
|
||||
mv /tmp/.buildx-cache-new /tmp/.buildx-cache
|
||||
|
||||
- name: Build 'ssl-bump' image for ghcr
|
||||
uses: docker/build-push-action@v7
|
||||
uses: docker/build-push-action@v4
|
||||
with:
|
||||
context: ssl-bump
|
||||
push: true
|
||||
|
||||
@@ -18,7 +18,7 @@ jobs:
|
||||
pull-requests: write
|
||||
|
||||
steps:
|
||||
- uses: actions/stale@v10
|
||||
- uses: actions/stale@v8
|
||||
with:
|
||||
days-before-stale: 182
|
||||
days-before-close: 7
|
||||
|
||||
+20
-17
@@ -1,6 +1,6 @@
|
||||
FROM alpine:3.23.3 AS build
|
||||
FROM alpine:3.17.3 as build
|
||||
|
||||
ARG SQUID_VER=7.5
|
||||
ARG SQUID_VER=6.0.2
|
||||
|
||||
RUN set -x && \
|
||||
apk add --no-cache \
|
||||
@@ -24,8 +24,8 @@ RUN set -x && \
|
||||
WORKDIR /tmp/build
|
||||
|
||||
RUN set -x && \
|
||||
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 -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
|
||||
curl -SsL http://www.squid-cache.org/Versions/v${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
|
||||
|
||||
COPY squid-keys.asc /tmp/build
|
||||
|
||||
@@ -58,7 +58,7 @@ RUN set -x && \
|
||||
--disable-arch-native \
|
||||
--enable-removal-policies="lru,heap" \
|
||||
--enable-auth-digest \
|
||||
--enable-auth-basic="getpwnam,NCSA,DB,RADIUS" \
|
||||
--enable-auth-basic="getpwnam,NCSA,DB" \
|
||||
--enable-basic-auth-helpers="DB" \
|
||||
--enable-epoll \
|
||||
--enable-external-acl-helpers="file_userip,unix_group,wbinfo_group" \
|
||||
@@ -86,7 +86,7 @@ RUN set -x && \
|
||||
--enable-storeio="diskd rock" \
|
||||
--enable-ipv6 \
|
||||
--enable-translation \
|
||||
--enable-snmp \
|
||||
--disable-snmp \
|
||||
--disable-dependency-tracking \
|
||||
--with-large-files \
|
||||
--with-default-user=squid \
|
||||
@@ -98,15 +98,18 @@ RUN set -x && \
|
||||
make -j $nproc && \
|
||||
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 && \
|
||||
echo 'include /etc/squid/conf.d.tail/*.conf' >> /etc/squid/squid.conf
|
||||
|
||||
# --- --- --- --- --- --- --- --- ---
|
||||
|
||||
FROM alpine:3.23.3
|
||||
FROM alpine:3.17.3
|
||||
|
||||
ENV SQUID_CONFIG_FILE=/etc/squid/squid.conf
|
||||
ENV TZ=Europe/Moscow
|
||||
ENV SQUID_CONFIG_FILE /etc/squid/squid.conf
|
||||
ENV TZ Europe/Moscow
|
||||
|
||||
RUN set -x && \
|
||||
deluser squid 2>/dev/null; delgroup squid 2>/dev/null; \
|
||||
@@ -116,17 +119,13 @@ RUN apk add --no-cache \
|
||||
libstdc++ \
|
||||
heimdal-libs \
|
||||
libcap \
|
||||
libltdl \
|
||||
apache2-utils \
|
||||
curl \
|
||||
tzdata
|
||||
libltdl
|
||||
|
||||
COPY --from=build /etc/squid/ /etc/squid/
|
||||
COPY --from=build /usr/lib/squid/ /usr/lib/squid/
|
||||
COPY --from=build /usr/share/squid/ /usr/share/squid/
|
||||
COPY --from=build /usr/sbin/squid /usr/sbin/squid
|
||||
|
||||
COPY --chmod=755 run.sh /
|
||||
COPY --from=build /usr/bin/squidclient /usr/bin/squidclient
|
||||
|
||||
RUN install -d -o squid -g squid \
|
||||
/var/cache/squid \
|
||||
@@ -137,12 +136,16 @@ RUN install -d -o squid -g squid \
|
||||
/etc/squid/conf.d \
|
||||
/etc/squid/conf.d.tail && \
|
||||
touch /etc/squid/conf.d/placeholder.conf
|
||||
COPY localnet.conf /etc/squid/conf.d/
|
||||
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"]
|
||||
EXPOSE 3128/tcp
|
||||
|
||||
USER squid
|
||||
|
||||
CMD ["/run.sh"]
|
||||
CMD ["sh", "-c", "/usr/sbin/squid -f ${SQUID_CONFIG_FILE} --foreground -z && exec /usr/sbin/squid -f ${SQUID_CONFIG_FILE} --foreground -YCd 1"]
|
||||
|
||||
@@ -30,21 +30,9 @@ docker-compose up
|
||||
|
||||
# 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:
|
||||
|
||||
- **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:
|
||||
|
||||
|
||||
@@ -1,8 +1,9 @@
|
||||
version: '2.3'
|
||||
services:
|
||||
proxy:
|
||||
image: "${TEST_TAG}"
|
||||
healthcheck:
|
||||
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'"]
|
||||
test: ["CMD", "sh", "-exc", "squidclient -T 3 mgr:info 2> /dev/null | grep -qF '200 OK'"]
|
||||
interval: 5s
|
||||
timeout: 3s
|
||||
retries: 5
|
||||
@@ -13,4 +14,5 @@ services:
|
||||
- proxy
|
||||
depends_on:
|
||||
- proxy
|
||||
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'"
|
||||
command: sh -exc "sleep 10 && squidclient -h proxy -T 3 'https://postman-echo.com/get?squidtest=ok' 2> /dev/null | grep -qF '200 OK'"
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
version: '2'
|
||||
services:
|
||||
squid:
|
||||
image: 'b4tman/squid'
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
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
|
||||
@@ -1,14 +0,0 @@
|
||||
#!/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.
+1
-6
@@ -1,9 +1,4 @@
|
||||
FROM b4tman/squid
|
||||
|
||||
COPY run.sh /
|
||||
USER root
|
||||
RUN chmod 755 /run.sh
|
||||
|
||||
USER squid
|
||||
|
||||
CMD ["/run.sh"]
|
||||
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"]
|
||||
@@ -1,19 +0,0 @@
|
||||
#!/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