Apache HTTP container images based on Red Hat Software Collections and intended for OpenShift and general usage. Users can choose between Red Hat Enterprise Linux, Fedora, and CentOS based images.
This change does a small modification how files in httpd-pre-init are identified and process to allow processing scripts provided via ConfigMap in OpenShift Container Platform.
Previous functionality should not be impacted as things still work as expected, but can now be hierarchically build if needed. The below shows a regular Source-to-Image build in OpenShift Container Platform 4 to show-case that the change does not impact existing functionality.
The resulting pod is showing expected behavior and running both scripts created in the git repository
$ oc logs httpd-84d7895c77-6s6f5
=> sourcing /opt/app-root/src/httpd-pre-init/script.sh ...
Test 1 script start ...
Test 1 script end ...
=> sourcing /opt/app-root/src/httpd-pre-init/script2.sh ...
Test 2 script start ...
Test 2 script end ...
=> sourcing [10-set-mpm.sh](http://10-set-mpm.sh/) ...
=> sourcing [20-copy-config.sh](http://20-copy-config.sh/) ...
=> sourcing [40-ssl-certs.sh](http://40-ssl-certs.sh/) ...
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using [10.129.2.35](http://10.129.2.35/). Set the 'ServerName' directive globally to suppress this message
[Tue Mar 29 06:48:55.943438 2022] [ssl:warn] [pid 1:tid 139883805257152] AH01909: [10.129.2.35](http://10.129.2.35/):8443:0 server certificate does NOT include an ID which matches the server name
[Tue Mar 29 06:48:55.943606 2022] [:notice] [pid 1:tid 139883805257152] ModSecurity for Apache/2.9.2 (http://www.modsecurity.org/) configured.
[Tue Mar 29 06:48:55.943614 2022] [:notice] [pid 1:tid 139883805257152] ModSecurity: APR compiled version="1.6.3"; loaded version="1.6.3"
[Tue Mar 29 06:48:55.943617 2022] [:notice] [pid 1:tid 139883805257152] ModSecurity: PCRE compiled version="8.42 "; loaded version="8.42 2018-03-20"
[Tue Mar 29 06:48:55.943622 2022] [:notice] [pid 1:tid 139883805257152] ModSecurity: LUA compiled version="Lua 5.3"
[Tue Mar 29 06:48:55.943624 2022] [:notice] [pid 1:tid 139883805257152] ModSecurity: YAJL compiled version="2.1.0"
[Tue Mar 29 06:48:55.943626 2022] [:notice] [pid 1:tid 139883805257152] ModSecurity: LIBXML compiled version="2.9.7"
[Tue Mar 29 06:48:55.943628 2022] [:notice] [pid 1:tid 139883805257152] ModSecurity: Status engine is currently disabled, enable it by set SecStatusEngine to On.
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using [10.129.2.35](http://10.129.2.35/). Set the 'ServerName' directive globally to suppress this message
[Tue Mar 29 06:48:56.019112 2022] [ssl:warn] [pid 1:tid 139883805257152] AH01909: [10.129.2.35](http://10.129.2.35/):8443:0 server certificate does NOT include an ID which matches the server name
[Tue Mar 29 06:48:56.019250 2022] [lbmethod_heartbeat:notice] [pid 1:tid 139883805257152] AH02282: No slotmem from mod_heartmonitor
[Tue Mar 29 06:48:56.023177 2022] [mpm_event:notice] [pid 1:tid 139883805257152] AH00489: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k configured -- resuming normal operations
[Tue Mar 29 06:48:56.023195 2022] [core:notice] [pid 1:tid 139883805257152] AH00094: Command line: 'httpd -D FOREGROUND'
$ oc exec httpd-84d7895c77-6s6f5 -- ls -lR /tmp/{test1,test2}
/tmp/test1:
total 4
-rw-r--r--. 1 1001450000 root 14 Mar 29 06:48 file.data
/tmp/test2:
total 4
-rw-r--r--. 1 1001450000 root 14 Mar 29 06:48 file.data
But with the new Image, we can now also just reference a ConfigMap as volume and trigger scripts that way. With that, it's no longer required to run a source-to-image build to have the httpd-pre-init populated but instead you can just run the Image and source the scripts from the ConfigMap.
The resulting pod shows again that the scripts mounted via ConfigMap are sources and executed as expected.
$ oc logs httpd-map-fbf78c84d-784n5
=> sourcing /opt/app-root/src/httpd-pre-init/..2022_03_29_06_44_03.941907033/script1.sh ...
Test 1 script start ...
Test 1 script end ...
=> sourcing /opt/app-root/src/httpd-pre-init/..2022_03_29_06_44_03.941907033/script2.sh ...
Test 2 script start ...
Test 2 script end ...
=> sourcing [10-set-mpm.sh](http://10-set-mpm.sh/) ...
=> sourcing [20-copy-config.sh](http://20-copy-config.sh/) ...
=> sourcing [40-ssl-certs.sh](http://40-ssl-certs.sh/) ...
---> Generating SSL key pair for httpd...
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using [10.130.2.197](http://10.130.2.197/). Set the 'ServerName' directive globally to suppress this message
[Tue Mar 29 06:44:10.257208 2022] [ssl:warn] [pid 1:tid 140544982937024] AH01909: [10.130.2.197](http://10.130.2.197/):8443:0 server certificate does NOT include an ID which matches the server name
[Tue Mar 29 06:44:10.257303 2022] [:notice] [pid 1:tid 140544982937024] ModSecurity for Apache/2.9.2 (http://www.modsecurity.org/) configured.
[Tue Mar 29 06:44:10.257308 2022] [:notice] [pid 1:tid 140544982937024] ModSecurity: APR compiled version="1.6.3"; loaded version="1.6.3"
[Tue Mar 29 06:44:10.257310 2022] [:notice] [pid 1:tid 140544982937024] ModSecurity: PCRE compiled version="8.42 "; loaded version="8.42 2018-03-20"
[Tue Mar 29 06:44:10.257314 2022] [:notice] [pid 1:tid 140544982937024] ModSecurity: LUA compiled version="Lua 5.3"
[Tue Mar 29 06:44:10.257314 2022] [:notice] [pid 1:tid 140544982937024] ModSecurity: YAJL compiled version="2.1.0"
[Tue Mar 29 06:44:10.257315 2022] [:notice] [pid 1:tid 140544982937024] ModSecurity: LIBXML compiled version="2.9.7"
[Tue Mar 29 06:44:10.257317 2022] [:notice] [pid 1:tid 140544982937024] ModSecurity: Status engine is currently disabled, enable it by set SecStatusEngine to On.
AH00558: httpd: Could not reliably determine the server's fully qualified domain name, using [10.130.2.197](http://10.130.2.197/). Set the 'ServerName' directive globally to suppress this message
[Tue Mar 29 06:44:10.324359 2022] [ssl:warn] [pid 1:tid 140544982937024] AH01909: [10.130.2.197](http://10.130.2.197/):8443:0 server certificate does NOT include an ID which matches the server name
[Tue Mar 29 06:44:10.324458 2022] [lbmethod_heartbeat:notice] [pid 1:tid 140544982937024] AH02282: No slotmem from mod_heartmonitor
[Tue Mar 29 06:44:10.327214 2022] [mpm_event:notice] [pid 1:tid 140544982937024] AH00489: Apache/2.4.37 (Red Hat Enterprise Linux) OpenSSL/1.1.1k configured -- resuming normal operations
[Tue Mar 29 06:44:10.327229 2022] [core:notice] [pid 1:tid 140544982937024] AH00094: Command line: 'httpd -D FOREGROUND'
$ oc exec httpd-map-fbf78c84d-784n5 -- ls -lR /tmp/{test1,test2}
/tmp/test1:
total 4
-rw-r--r--. 1 1001450000 root 14 Mar 29 06:44 file.data
/tmp/test2:
total 4
-rw-r--r--. 1 1001450000 root 14 Mar 29 06:44 file.data
Using find -L instead of -maxdepth 10 was not working, as the ConfigMap mounts the scripts using symlinks multiple times. Therefore, with the given approach a lot of refactoring of the original Code would be required to make it work and avoid duplicated execution of the scripts.
This change does a small modification how files in
httpd-pre-init
are identified and process to allow processing scripts provided viaConfigMap
in OpenShift Container Platform.Previous functionality should not be impacted as things still work as expected, but can now be hierarchically build if needed. The below shows a regular Source-to-Image build in OpenShift Container Platform 4 to show-case that the change does not impact existing functionality.
The resulting pod is showing expected behavior and running both scripts created in the
git
repositoryBut with the new Image, we can now also just reference a
ConfigMap
asvolume
and trigger scripts that way. With that, it's no longer required to run a source-to-image build to have thehttpd-pre-init
populated but instead you can just run the Image and source the scripts from theConfigMap
.The resulting pod shows again that the scripts mounted via
ConfigMap
are sources and executed as expected.Using
find -L
instead of-maxdepth 10
was not working, as theConfigMap
mounts the scripts using symlinks multiple times. Therefore, with the given approach a lot of refactoring of the original Code would be required to make it work and avoid duplicated execution of the scripts.