This is an automated email from the ASF dual-hosted git repository.

sebb pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/attic-docker.git


The following commit(s) were added to refs/heads/main by this push:
     new 24d4f3e  Use wrapper to override hostname
24d4f3e is described below

commit 24d4f3e0c24038c5a091e5696019fe37c54d09e2
Author: Sebb <[email protected]>
AuthorDate: Thu Oct 9 17:46:33 2025 +0100

    Use wrapper to override hostname
    
    Allows use of unmodified attic_filter
    Drop change to attic_filter
    Sync override settings with TLP server
---
 Dockerfile               |  4 +++-
 _docker/000-default.conf |  9 +++++++--
 _docker/wrapper.lua      | 18 ++++++++++++++++++
 scripts/attic_filter.lua |  6 ------
 4 files changed, 28 insertions(+), 9 deletions(-)

diff --git a/Dockerfile b/Dockerfile
index 3e483ec..2471283 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -7,7 +7,6 @@ ENV GEM_HOME="/srv/gems" \
 RUN apt-get update && \
     DEBIAN_FRONTEND='noninteractive' apt-get install -y \
       apache2
-RUN echo "ServerName apache-lua.local" > 
/etc/apache2/conf-enabled/servername.conf
 
 RUN DEBIAN_FRONTEND='noninteractive' apt-get install -y \
   lua5.2 \
@@ -23,8 +22,11 @@ RUN a2enmod cgi && \
 RUN apt-get update && DEBIAN_FRONTEND='noninteractive' apt-get install -y \
   vim
     
+RUN echo "ServerName apache-lua.local" > 
/etc/apache2/conf-enabled/servername.conf
+
 COPY _docker/000-default.conf /etc/apache2/sites-enabled/000-default.conf
 COPY scripts/attic_filter.lua /etc/apache2/conf-enabled/attic_filter.lua
+COPY _docker/wrapper.lua /etc/apache2/conf-enabled/wrapper.lua
 
 EXPOSE 80
 
diff --git a/_docker/000-default.conf b/_docker/000-default.conf
index 1ef902f..3f9c9eb 100644
--- a/_docker/000-default.conf
+++ b/_docker/000-default.conf
@@ -19,7 +19,9 @@
 
        # Allow .htaccess Header set CSP
        <Directory /var/www/site.apache.org/>
-               AllowOverride FileInfo
+               # from TLP node definition
+               AllowOverride All
+               Options Indexes FollowSymLinks MultiViews ExecCGI
                # We don't want to generate an index with index.cgi, as that 
invokes closer.lua
                DirectoryIndex disabled
                DirectoryIndex index.html
@@ -47,7 +49,10 @@
        </Directory>
 
        # Filter website to add Attic header if marker directory is present
-       LuaOutputFilter attic "/etc/apache2/conf-enabled/attic_filter.lua" 
output_filter
+       # LuaOutputFilter attic "/etc/apache2/conf-enabled/attic_filter.lua" 
output_filter
+       # Wrapper to allow override of hostname
+       LuaPackagePath /etc/apache2/conf-enabled/?.lua
+       LuaOutputFilter attic "/etc/apache2/conf-enabled/wrapper.lua" 
output_filter_wrapper
        <If "-d '/var/www/site.apache.org/_ATTIC' || env('VAR_ATTIC') == 'yes'">
                AddOutputFilter attic html lua
        </If>
diff --git a/_docker/wrapper.lua b/_docker/wrapper.lua
new file mode 100644
index 0000000..5a9bf26
--- /dev/null
+++ b/_docker/wrapper.lua
@@ -0,0 +1,18 @@
+--[[
+    This wrapper modifies the hostname in the argument passed to the filter 
handler.
+]]
+require 'attic_filter'
+
+function output_filter_wrapper(r)
+    -- copy the variables needed by attic_filter, overriding hostname
+    -- it's not possible to update hostname in the userdata (r), so we provide 
a replacment which uses the same syntax
+    s = {}
+    -- Copy across the items need by the filter.
+    s['content_type'] = r.content_type
+    s['hostname'] = os.getenv('VAR_NAME') or 'localhost'
+    -- For local debugging, also add the following:
+    s['warn'] = function(self, txt)
+        r:warn(txt)
+    end
+    output_filter(s) -- call with updated settings
+end
diff --git a/scripts/attic_filter.lua b/scripts/attic_filter.lua
index 1e52eb4..8c54c05 100644
--- a/scripts/attic_filter.lua
+++ b/scripts/attic_filter.lua
@@ -37,12 +37,6 @@ function output_filter(r)
     -- get TLP part of hostname
     local host = r.hostname:match("^([^.]+)")
 
-    -- Allow override of host name
-    if host == 'localhost'
-    then
-        host = os.getenv('VAR_NAME') or 'unknown'
-    end
-
     -- create the customised banner
     local divstyle = 
'font-size:x-large;padding:15px;color:white;background:red;z-index:99;' ;
     local astyle = 'color:white;text-decoration:underline' ;

Reply via email to