2026-10-22 06:58:16 -07:00
|
|
|
# Base image. CI passes BASE_IMAGE=almalinux/10-base@sha256:<digest>, resolved
|
|
|
|
|
# DIRECTLY from Docker Hub in the same run (.gitea/scripts/resolve-base-image.sh),
|
|
|
|
|
# so the pkg-cache registry mirror can only serve content-addressed blobs.
|
|
|
|
|
# Local builds use the tag. docs/pkg-cache.md "Base-image digest pinning".
|
|
|
|
|
ARG BASE_IMAGE=almalinux/10-base
|
2026-11-23 07:20:15 -08:00
|
|
|
|
|
|
|
|
# Build stage for mod_whp_proxy_guard (src/mod_whp_proxy_guard/): compiled
|
|
|
|
|
# against the distribution httpd-devel, so the runtime keeps the stock
|
|
|
|
|
# AlmaLinux httpd RPMs and their security updates. Only the .so (and the httpd
|
|
|
|
|
# version it was built against) reaches the image.
|
|
|
|
|
FROM ${BASE_IMAGE} AS modbuild-proxyguard
|
|
|
|
|
ARG PKG_CACHE=
|
|
|
|
|
COPY ./scripts/pkg-cache-repos.sh /usr/local/sbin/pkg-cache-repos.sh
|
|
|
|
|
COPY ./keys/pkg-cache/ /usr/local/share/pkg-cache/
|
|
|
|
|
COPY ./src/mod_whp_proxy_guard/mod_whp_proxy_guard.c /src/mod_whp_proxy_guard.c
|
|
|
|
|
RUN /usr/local/sbin/pkg-cache-repos.sh rpm && \
|
|
|
|
|
dnf update -y && \
|
|
|
|
|
dnf install -y httpd-devel gcc redhat-rpm-config && \
|
|
|
|
|
/usr/local/sbin/pkg-cache-repos.sh restore && \
|
|
|
|
|
cd /src && apxs -Wc,-Wall -Wc,-Werror -c mod_whp_proxy_guard.c && \
|
|
|
|
|
rpm -q --qf '%{VERSION}-%{RELEASE}' httpd-devel > /src/built-against
|
2026-10-22 06:58:16 -07:00
|
|
|
FROM ${BASE_IMAGE}
|
2026-04-01 10:08:00 -07:00
|
|
|
|
2026-10-21 12:53:24 -07:00
|
|
|
# OPTIONAL internal package cache, e.g. --build-arg PKG_CACHE=https://192.168.1.40
|
|
|
|
|
# (CT130 pkg-cache, https only). Unset = upstream repositories. Release RPMs are
|
|
|
|
|
# GPG-verified against keys/pkg-cache/ either way. Repo files
|
2026-10-21 12:29:54 -07:00
|
|
|
# are restored at the end of every RUN, so no layer keeps the cache address.
|
|
|
|
|
# See scripts/pkg-cache-repos.sh.
|
|
|
|
|
ARG PKG_CACHE=
|
|
|
|
|
COPY ./scripts/pkg-cache-repos.sh /usr/local/sbin/pkg-cache-repos.sh
|
2026-10-21 12:53:24 -07:00
|
|
|
COPY ./keys/pkg-cache/ /usr/local/share/pkg-cache/
|
2026-10-21 12:29:54 -07:00
|
|
|
|
2026-04-01 10:08:00 -07:00
|
|
|
# Install Apache and minimal dependencies (no PHP at all)
|
2026-10-21 12:29:54 -07:00
|
|
|
RUN /usr/local/sbin/pkg-cache-repos.sh rpm && \
|
2026-10-21 12:53:24 -07:00
|
|
|
/usr/local/sbin/pkg-cache-repos.sh release-install epel && \
|
2026-10-21 12:29:54 -07:00
|
|
|
/usr/local/sbin/pkg-cache-repos.sh rpm && \
|
2026-04-01 10:08:00 -07:00
|
|
|
dnf update -y && \
|
2026-04-01 11:11:10 -07:00
|
|
|
dnf install -y httpd mod_ssl openssl iproute cronie procps curl && \
|
2026-10-21 12:29:54 -07:00
|
|
|
/usr/local/sbin/pkg-cache-repos.sh restore && \
|
2026-04-01 10:08:00 -07:00
|
|
|
dnf clean all && \
|
|
|
|
|
rm -rf /var/cache/dnf /usr/share/doc /usr/share/man /usr/share/locale/*
|
|
|
|
|
|
|
|
|
|
# Copy scripts and set permissions
|
|
|
|
|
COPY ./scripts/detect-memory.sh /scripts/detect-memory.sh
|
|
|
|
|
COPY ./scripts/create-apache-mpm-config.sh /scripts/create-apache-mpm-config.sh
|
|
|
|
|
COPY ./scripts/log-rotate.sh /scripts/log-rotate.sh
|
|
|
|
|
COPY ./scripts/entrypoint-shared-httpd.sh /scripts/entrypoint-shared-httpd.sh
|
2026-10-20 15:44:14 -07:00
|
|
|
COPY ./scripts/stop-services.sh /scripts/stop-services.sh
|
2026-04-01 10:08:00 -07:00
|
|
|
COPY ./scripts/tune-mpm.sh /scripts/tune-mpm.sh
|
2026-11-12 05:58:57 -08:00
|
|
|
COPY ./scripts/httpd-h2-md-gate.sh /scripts/httpd-h2-md-gate.sh
|
2026-04-01 10:08:00 -07:00
|
|
|
RUN chmod +x /scripts/*
|
|
|
|
|
|
|
|
|
|
# Generate self-signed SSL cert (same as main CAC image)
|
|
|
|
|
RUN openssl req -newkey rsa:2048 -nodes \
|
|
|
|
|
-keyout /etc/pki/tls/private/localhost.key \
|
|
|
|
|
-x509 -days 3650 -subj "/CN=localhost" \
|
|
|
|
|
-out /etc/pki/tls/certs/localhost.crt
|
|
|
|
|
|
|
|
|
|
# Copy Apache configs
|
|
|
|
|
COPY ./configs/remote_ip.conf /etc/httpd/conf.d/
|
|
|
|
|
COPY ./configs/default-index.conf /etc/httpd/conf.d/
|
|
|
|
|
|
2026-11-23 07:20:15 -08:00
|
|
|
# mod_whp_proxy_guard: request-time proxy allow list, .htaccess
|
|
|
|
|
# ProxyFCGISetEnvIf refusal, FastCGI env scrub and handler deny list
|
|
|
|
|
# (configs/whp-proxy-guard.conf). Loaded after mod_proxy (99-), which its
|
|
|
|
|
# scheme_handler hook needs. The build fails if the runtime httpd differs from
|
|
|
|
|
# the httpd-devel it was compiled against, or if the module does not load.
|
|
|
|
|
COPY --from=modbuild-proxyguard /src/.libs/mod_whp_proxy_guard.so /usr/lib64/httpd/modules/mod_whp_proxy_guard.so
|
|
|
|
|
COPY --from=modbuild-proxyguard /src/built-against /usr/lib64/httpd/modules/mod_whp_proxy_guard.built-against
|
|
|
|
|
COPY ./configs/whp-proxy-guard.conf /etc/httpd/conf.d/whp-proxy-guard.conf
|
|
|
|
|
RUN echo 'LoadModule whp_proxy_guard_module modules/mod_whp_proxy_guard.so' > /etc/httpd/conf.modules.d/99-whp-proxy-guard.conf && \
|
|
|
|
|
test "$(rpm -q --qf '%{VERSION}-%{RELEASE}' httpd)" = "$(cat /usr/lib64/httpd/modules/mod_whp_proxy_guard.built-against)" && \
|
|
|
|
|
httpd -t && httpd -M 2>/dev/null | grep -q ' whp_proxy_guard_module '
|
|
|
|
|
|
2026-04-01 10:08:00 -07:00
|
|
|
# Create vhosts directory (will be volume-mounted from host)
|
|
|
|
|
RUN mkdir -p /etc/httpd/conf.d/vhosts
|
|
|
|
|
|
|
|
|
|
# Set up cron job for log rotation
|
|
|
|
|
RUN echo "15 */12 * * * root /scripts/log-rotate.sh" >> /etc/crontab
|
|
|
|
|
|
2026-11-12 05:58:57 -08:00
|
|
|
# CVE-2026-119618 defense in depth: no HTTP/2 / mod_md in the image, build fails
|
|
|
|
|
# if they come back or the config no longer parses. scripts/httpd-h2-md-gate.sh.
|
|
|
|
|
# Placed after every other package step so nothing later can re-add them.
|
|
|
|
|
RUN /scripts/httpd-h2-md-gate.sh remove && /scripts/httpd-h2-md-gate.sh check
|
|
|
|
|
LABEL org.whp.httpd-h2-md="removed"
|
|
|
|
|
|
2026-04-01 10:08:00 -07:00
|
|
|
EXPOSE 80 443
|
|
|
|
|
|
|
|
|
|
HEALTHCHECK --interval=30s --timeout=5s --start-period=60s --retries=3 \
|
|
|
|
|
CMD curl -sfk https://localhost/ping || exit 1
|
|
|
|
|
|
|
|
|
|
ENTRYPOINT [ "/scripts/entrypoint-shared-httpd.sh" ]
|