Devilbox: How to enable Apache 2.4 modules?

Created on 28 Nov 2019  路  6Comments  路  Source: cytopia/devilbox

I would like to enable a few modules for Apache 2.4.
Entering the container of the image devilbox/apache-2.4:0.30 I can see the following modules.

root@httpd:/usr/local/apache2/modules# ls -la
total 5152
drwxr-sr-x 2 root     www-data   4096 Feb 12  2019 .
drwxr-sr-x 1 www-data www-data   4096 Nov 28 15:34 ..
-rw-r--r-- 1 root     src       15727 Feb 12  2019 httpd.exp
-rwxr-xr-x 1 root     www-data  13752 Feb 12  2019 mod_access_compat.so
-rwxr-xr-x 1 root     www-data  13488 Feb 12  2019 mod_actions.so
-rwxr-xr-x 1 root     www-data  22896 Feb 12  2019 mod_alias.so
-rwxr-xr-x 1 root     www-data  13056 Feb 12  2019 mod_allowmethods.so
-rwxr-xr-x 1 root     www-data  13184 Feb 12  2019 mod_asis.so
-rwxr-xr-x 1 root     www-data  22344 Feb 12  2019 mod_auth_basic.so
-rwxr-xr-x 1 root     www-data  50968 Feb 12  2019 mod_auth_digest.so
-rwxr-xr-x 1 root     www-data  36760 Feb 12  2019 mod_auth_form.so
-rwxr-xr-x 1 root     www-data  13136 Feb 12  2019 mod_authn_anon.so
-rwxr-xr-x 1 root     www-data  18464 Feb 12  2019 mod_authn_core.so
-rwxr-xr-x 1 root     www-data  18144 Feb 12  2019 mod_authn_dbd.so
-rwxr-xr-x 1 root     www-data  13560 Feb 12  2019 mod_authn_dbm.so
-rwxr-xr-x 1 root     www-data  13400 Feb 12  2019 mod_authn_file.so
-rwxr-xr-x 1 root     www-data  27736 Feb 12  2019 mod_authn_socache.so
-rwxr-xr-x 1 root     www-data  45440 Feb 12  2019 mod_authnz_fcgi.so
-rwxr-xr-x 1 root     www-data  78960 Feb 12  2019 mod_authnz_ldap.so
-rwxr-xr-x 1 root     www-data  32512 Feb 12  2019 mod_authz_core.so
-rwxr-xr-x 1 root     www-data  18664 Feb 12  2019 mod_authz_dbd.so
-rwxr-xr-x 1 root     www-data  18104 Feb 12  2019 mod_authz_dbm.so
-rwxr-xr-x 1 root     www-data  18416 Feb 12  2019 mod_authz_groupfile.so
-rwxr-xr-x 1 root     www-data  18496 Feb 12  2019 mod_authz_host.so
-rwxr-xr-x 1 root     www-data  13136 Feb 12  2019 mod_authz_owner.so
-rwxr-xr-x 1 root     www-data  13200 Feb 12  2019 mod_authz_user.so
-rwxr-xr-x 1 root     www-data  50160 Feb 12  2019 mod_autoindex.so
-rwxr-xr-x 1 root     www-data  13352 Feb 12  2019 mod_bucketeer.so
-rwxr-xr-x 1 root     www-data  13648 Feb 12  2019 mod_buffer.so
-rwxr-xr-x 1 root     www-data 111720 Feb 12  2019 mod_cache.so
-rwxr-xr-x 1 root     www-data  49496 Feb 12  2019 mod_cache_disk.so
-rwxr-xr-x 1 root     www-data  49576 Feb 12  2019 mod_cache_socache.so
-rwxr-xr-x 1 root     www-data  13488 Feb 12  2019 mod_case_filter.so
-rwxr-xr-x 1 root     www-data  13360 Feb 12  2019 mod_case_filter_in.so
-rwxr-xr-x 1 root     www-data  13872 Feb 12  2019 mod_cern_meta.so
-rwxr-xr-x 1 root     www-data  38536 Feb 12  2019 mod_cgi.so
-rwxr-xr-x 1 root     www-data  57976 Feb 12  2019 mod_cgid.so
-rwxr-xr-x 1 root     www-data  31296 Feb 12  2019 mod_charset_lite.so
-rwxr-xr-x 1 root     www-data  13712 Feb 12  2019 mod_data.so
-rwxr-xr-x 1 root     www-data 132136 Feb 12  2019 mod_dav.so
-rwxr-xr-x 1 root     www-data  71128 Feb 12  2019 mod_dav_fs.so
-rwxr-xr-x 1 root     www-data  23520 Feb 12  2019 mod_dav_lock.so
-rwxr-xr-x 1 root     www-data  28112 Feb 12  2019 mod_dbd.so
-rwxr-xr-x 1 root     www-data  53200 Feb 12  2019 mod_deflate.so
-rwxr-xr-x 1 root     www-data  18256 Feb 12  2019 mod_dialup.so
-rwxr-xr-x 1 root     www-data  18128 Feb 12  2019 mod_dir.so
-rwxr-xr-x 1 root     www-data  17552 Feb 12  2019 mod_dumpio.so
-rwxr-xr-x 1 root     www-data  13760 Feb 12  2019 mod_echo.so
-rwxr-xr-x 1 root     www-data  13520 Feb 12  2019 mod_env.so
-rwxr-xr-x 1 root     www-data  29144 Feb 12  2019 mod_example_hooks.so
-rwxr-xr-x 1 root     www-data  14336 Feb 12  2019 mod_example_ipc.so
-rwxr-xr-x 1 root     www-data  18392 Feb 12  2019 mod_expires.so
-rwxr-xr-x 1 root     www-data  33072 Feb 12  2019 mod_ext_filter.so
-rwxr-xr-x 1 root     www-data  18760 Feb 12  2019 mod_file_cache.so
-rwxr-xr-x 1 root     www-data  26904 Feb 12  2019 mod_filter.so
-rwxr-xr-x 1 root     www-data  29104 Feb 12  2019 mod_headers.so
-rwxr-xr-x 1 root     www-data  13824 Feb 12  2019 mod_heartbeat.so
-rwxr-xr-x 1 root     www-data  33048 Feb 12  2019 mod_heartmonitor.so
-rwxr-xr-x 1 root     www-data 410528 Feb 12  2019 mod_http2.so
-rwxr-xr-x 1 root     www-data  13720 Feb 12  2019 mod_ident.so
-rwxr-xr-x 1 root     www-data  22816 Feb 12  2019 mod_imagemap.so
-rwxr-xr-x 1 root     www-data  71840 Feb 12  2019 mod_include.so
-rwxr-xr-x 1 root     www-data  34856 Feb 12  2019 mod_info.so
-rwxr-xr-x 1 root     www-data  45000 Feb 12  2019 mod_isapi.so
-rwxr-xr-x 1 root     www-data  13056 Feb 12  2019 mod_lbmethod_bybusyness.so
-rwxr-xr-x 1 root     www-data   8960 Feb 12  2019 mod_lbmethod_byrequests.so
-rwxr-xr-x 1 root     www-data   8952 Feb 12  2019 mod_lbmethod_bytraffic.so
-rwxr-xr-x 1 root     www-data  19200 Feb 12  2019 mod_lbmethod_heartbeat.so
-rwxr-xr-x 1 root     www-data 111864 Feb 12  2019 mod_ldap.so
-rwxr-xr-x 1 root     www-data  39552 Feb 12  2019 mod_log_config.so
-rwxr-xr-x 1 root     www-data  18728 Feb 12  2019 mod_log_debug.so
-rwxr-xr-x 1 root     www-data  18336 Feb 12  2019 mod_log_forensic.so
-rwxr-xr-x 1 root     www-data  14280 Feb 12  2019 mod_logio.so
-rwxr-xr-x 1 root     www-data 180016 Feb 12  2019 mod_lua.so
-rwxr-xr-x 1 root     www-data  22960 Feb 12  2019 mod_macro.so
-rwxr-xr-x 1 root     www-data  27416 Feb 12  2019 mod_mime.so
-rwxr-xr-x 1 root     www-data  36720 Feb 12  2019 mod_mime_magic.so
-rwxr-xr-x 1 root     www-data  88104 Feb 12  2019 mod_mpm_event.so
-rwxr-xr-x 1 root     www-data  44008 Feb 12  2019 mod_mpm_prefork.so
-rwxr-xr-x 1 root     www-data  63040 Feb 12  2019 mod_mpm_worker.so
-rwxr-xr-x 1 root     www-data  46776 Feb 12  2019 mod_negotiation.so
-rwxr-xr-x 1 root     www-data   8584 Feb 12  2019 mod_optional_fn_export.so
-rwxr-xr-x 1 root     www-data   8720 Feb 12  2019 mod_optional_fn_import.so
-rwxr-xr-x 1 root     www-data   8656 Feb 12  2019 mod_optional_hook_export.so
-rwxr-xr-x 1 root     www-data   8600 Feb 12  2019 mod_optional_hook_import.so
-rwxr-xr-x 1 root     www-data 177296 Feb 12  2019 mod_proxy.so
-rwxr-xr-x 1 root     www-data  79912 Feb 12  2019 mod_proxy_ajp.so
-rwxr-xr-x 1 root     www-data  72248 Feb 12  2019 mod_proxy_balancer.so
-rwxr-xr-x 1 root     www-data  26920 Feb 12  2019 mod_proxy_connect.so
-rwxr-xr-x 1 root     www-data  17872 Feb 12  2019 mod_proxy_express.so
-rwxr-xr-x 1 root     www-data  41272 Feb 12  2019 mod_proxy_fcgi.so
-rwxr-xr-x 1 root     www-data  13752 Feb 12  2019 mod_proxy_fdpass.so
-rwxr-xr-x 1 root     www-data  67216 Feb 12  2019 mod_proxy_ftp.so
-rwxr-xr-x 1 root     www-data  46848 Feb 12  2019 mod_proxy_hcheck.so
-rwxr-xr-x 1 root     www-data  50280 Feb 12  2019 mod_proxy_html.so
-rwxr-xr-x 1 root     www-data  59624 Feb 12  2019 mod_proxy_http.so
-rwxr-xr-x 1 root     www-data 111560 Feb 12  2019 mod_proxy_http2.so
-rwxr-xr-x 1 root     www-data  28176 Feb 12  2019 mod_proxy_scgi.so
-rwxr-xr-x 1 root     www-data  23576 Feb 12  2019 mod_proxy_uwsgi.so
-rwxr-xr-x 1 root     www-data  26616 Feb 12  2019 mod_proxy_wstunnel.so
-rwxr-xr-x 1 root     www-data  17976 Feb 12  2019 mod_ratelimit.so
-rwxr-xr-x 1 root     www-data  14144 Feb 12  2019 mod_reflector.so
-rwxr-xr-x 1 root     www-data  36536 Feb 12  2019 mod_remoteip.so
-rwxr-xr-x 1 root     www-data  18928 Feb 12  2019 mod_reqtimeout.so
-rwxr-xr-x 1 root     www-data  18248 Feb 12  2019 mod_request.so
-rwxr-xr-x 1 root     www-data  96472 Feb 12  2019 mod_rewrite.so
-rwxr-xr-x 1 root     www-data  53992 Feb 12  2019 mod_sed.so
-rwxr-xr-x 1 root     www-data  28120 Feb 12  2019 mod_session.so
-rwxr-xr-x 1 root     www-data  13792 Feb 12  2019 mod_session_cookie.so
-rwxr-xr-x 1 root     www-data  36232 Feb 12  2019 mod_session_crypto.so
-rwxr-xr-x 1 root     www-data  22832 Feb 12  2019 mod_session_dbd.so
-rwxr-xr-x 1 root     www-data  22648 Feb 12  2019 mod_setenvif.so
-rwxr-xr-x 1 root     www-data  13520 Feb 12  2019 mod_slotmem_plain.so
-rwxr-xr-x 1 root     www-data  23056 Feb 12  2019 mod_slotmem_shm.so
-rwxr-xr-x 1 root     www-data  22688 Feb 12  2019 mod_socache_dbm.so
-rwxr-xr-x 1 root     www-data  18352 Feb 12  2019 mod_socache_memcache.so
-rwxr-xr-x 1 root     www-data  34880 Feb 12  2019 mod_socache_shmcb.so
-rwxr-xr-x 1 root     www-data  18408 Feb 12  2019 mod_speling.so
-rwxr-xr-x 1 root     www-data 349736 Feb 12  2019 mod_ssl.so
-rwxr-xr-x 1 root     www-data  31376 Feb 12  2019 mod_status.so
-rwxr-xr-x 1 root     www-data  30936 Feb 12  2019 mod_substitute.so
-rwxr-xr-x 1 root     www-data  13384 Feb 12  2019 mod_suexec.so
-rwxr-xr-x 1 root     www-data  13512 Feb 12  2019 mod_unique_id.so
-rwxr-xr-x 1 root     www-data  18360 Feb 12  2019 mod_unixd.so
-rwxr-xr-x 1 root     www-data  13720 Feb 12  2019 mod_userdir.so
-rwxr-xr-x 1 root     www-data  18392 Feb 12  2019 mod_usertrack.so
-rwxr-xr-x 1 root     www-data  13240 Feb 12  2019 mod_version.so
-rwxr-xr-x 1 root     www-data  18008 Feb 12  2019 mod_vhost_alias.so
-rwxr-xr-x 1 root     www-data  28488 Feb 12  2019 mod_watchdog.so
-rwxr-xr-x 1 root     www-data  35984 Feb 12  2019 mod_xml2enc.so

I tried enabling the module with the Apache conf file using this documentation.
https://devilbox.readthedocs.io/en/latest/configuration-files/apache-conf.html

In the directory cfg/apache-2.4/ I made a file devilbox-apache-custom.conf with this content.

#
# Apache 2.4 configuration overwrites
#
# Make sure this file ends by *.conf, otherwise
# the configuration is not sourced by nginx.
#
# The below settings are just examples.
# Copy them, remove them or reset them.
#

LoadModule deflate_module /usr/local/apache2/modules/mod_deflate.so

using the path of where I found the modules in the Apache container.

However when I stop, remove and start Devilbox and run a Lighthouse audit I always get this result.

Screenshot_20191128_171858

Of course I have made sure to include this in the .htaccess file of the project.

    <IfModule mod_deflate.c>
        # Compress HTML, CSS, JavaScript, Text, XML and fonts
        AddOutputFilterByType DEFLATE application/javascript
        AddOutputFilterByType DEFLATE application/rss+xml
        AddOutputFilterByType DEFLATE application/vnd.ms-fontobject
        AddOutputFilterByType DEFLATE application/x-font
        AddOutputFilterByType DEFLATE application/x-font-opentype
        AddOutputFilterByType DEFLATE application/x-font-otf
        AddOutputFilterByType DEFLATE application/x-font-truetype
        AddOutputFilterByType DEFLATE application/x-font-ttf
        AddOutputFilterByType DEFLATE application/x-javascript
        AddOutputFilterByType DEFLATE application/xhtml+xml
        AddOutputFilterByType DEFLATE application/xml
        AddOutputFilterByType DEFLATE font/opentype
        AddOutputFilterByType DEFLATE font/otf
        AddOutputFilterByType DEFLATE font/ttf
        AddOutputFilterByType DEFLATE image/svg+xml
        AddOutputFilterByType DEFLATE image/x-icon
        AddOutputFilterByType DEFLATE text/css
        AddOutputFilterByType DEFLATE text/html
        AddOutputFilterByType DEFLATE text/javascript
        AddOutputFilterByType DEFLATE text/plain
        AddOutputFilterByType DEFLATE text/xml

        # Remove browser bugs (only needed for really old browsers)
        BrowserMatch ^Mozilla/4 gzip-only-text/html
        BrowserMatch ^Mozilla/4\.0[678] no-gzip
        BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
        Header append Vary User-Agent
    </IfModule>

Do I need to go into the Dockerfile here https://github.com/devilbox/docker-apache-2.4/blob/master/Dockerfile and enable the wanted module there or can I do this through the .conf file for Apache?

question waiting for reply

Most helpful comment

@robots4life can you let me know if @BrendonKoz solution is not working for you, otherwise I would go ahead and close this issue. FYI: Presented solution does work for me as well.

All 6 comments

Hmm. When I run root@httpd:/usr/local/apache2# apachectl -t -D DUMP_MODULES in the Apache container I get this.

Loaded Modules:
 core_module (static)
 so_module (static)
 http_module (static)
 mpm_event_module (shared)
 authn_file_module (shared)
 authn_core_module (shared)
 authz_host_module (shared)
 authz_groupfile_module (shared)
 authz_user_module (shared)
 authz_core_module (shared)
 access_compat_module (shared)
 auth_basic_module (shared)
 reqtimeout_module (shared)
 filter_module (shared)
 mime_module (shared)
 log_config_module (shared)
 env_module (shared)
 headers_module (shared)
 setenvif_module (shared)
 version_module (shared)
 unixd_module (shared)
 status_module (shared)
 autoindex_module (shared)
 dir_module (shared)
 alias_module (shared)
 http2_module (shared)
 proxy_module (shared)
 proxy_http_module (shared)
 proxy_http2_module (shared)
 proxy_fcgi_module (shared)
 rewrite_module (shared)
 deflate_module (shared)
 ssl_module (shared)
 socache_shmcb_module (shared)

So it seems the deflate_module is loaded, however Lighthouse, for some reason does not seem to see it working. Is there another way to check if the deflate_module is working?

The module is loaded correctly and is also available. I guess it's rather a configuration issue of the vhost/.htaccess file. Try playing around with this and check if it is working manually via wget

wget --header="Accept-Encoding: gzip" http://SERVER_IP/jquery-3.2.1.js

I needed to enable the Deflate module for my own testing so came upon this topic. I don't believe anything's changed in DevilBox that would make this behave differently from when this was posted until now. The solution resides in the path provided in the devilbox-custom.conf file for loading the module. You don't need (or want) to include the full path to the module -- it acts as if it is loaded from the base directory.

LoadModule deflate_module modules/mod_deflate.so

That should enable your DEFLATE module as expected. In my case I also needed the expires module:
LoadModule expires_module modules/mod_expires.so

Both are now loading fine and no longer causing 500 errors due to my .htaccess file.

@robots4life can you let me know if @BrendonKoz solution is not working for you, otherwise I would go ahead and close this issue. FYI: Presented solution does work for me as well.

I will check asap and report back, thank you both for your feedback on the issue.

All good, it works! It was the path. Thank you @BrendonKoz and @cytopia :+1: :rocket:

Was this page helpful?
0 / 5 - 0 ratings

Related issues

msyhr picture msyhr  路  7Comments

gowrav-vishwakarma picture gowrav-vishwakarma  路  6Comments

Venorcis picture Venorcis  路  6Comments

folkevil picture folkevil  路  5Comments

tmort picture tmort  路  7Comments