From 6e1d3e864c88ed2721bb8ac6c451c0a4ad0772d8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maciej=20P=C4=99dzich?= Date: Fri, 16 Aug 2024 09:35:58 +0200 Subject: [PATCH] Add a custom HTTPD config to log X-Forwarded-For IP --- Dockerfile | 1 + httpd.conf | 6 ++++++ 2 files changed, 7 insertions(+) create mode 100644 httpd.conf diff --git a/Dockerfile b/Dockerfile index ac136d4..2b29617 100644 --- a/Dockerfile +++ b/Dockerfile @@ -5,5 +5,6 @@ RUN npm i RUN npm run build FROM httpd:2.4-alpine AS runtime +COPY --from=build httpd.conf /usr/local/apache2/conf/httpd.conf COPY --from=build /app/dist /usr/local/apache2/htdocs/ EXPOSE 80 diff --git a/httpd.conf b/httpd.conf new file mode 100644 index 0000000..a9c7f5d --- /dev/null +++ b/httpd.conf @@ -0,0 +1,6 @@ +# Fields to record - use X-Forward-For instead of client IP so that we get the actual clients IP +LogFormat "%{X-Forwarded-For}i %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" mycustom + +# Log locations +CustomLog "/var/log/httpd/access.log" mycustom env=!dontlog +ErrorLog "/var/log/httpd/error.log"