[packages/apache] - Rel 2. config cleanup: deflate compresses json/feeds/fonts, no forced Vary; forward proxy local

arekm arekm at pld-linux.org
Sun Nov 22 13:48:26 CET 2026


commit a17f043f7aac211d70ecd1a5c939252dda583dcf
Author: Arkadiusz Miśkiewicz <arekm at maven.pl>
Date:   Sun Nov 22 12:46:26 2026 +0100

    - Rel 2. config cleanup: deflate compresses json/feeds/fonts, no forced Vary; forward proxy
      local only, ProxyPass works without <Proxy> grants; event MPM example; Type=notify unit;
      UserDir disabled root, no mod_userdir in meta; fixed VCS dir regex; htcacheclean service

 apache-common.conf            |  5 +--
 apache-htcacheclean.init      | 82 +++++++++++++++++++++++++++++++++++++++++++
 apache-htcacheclean.service   | 14 ++++++++
 apache-htcacheclean.sysconfig | 13 +++++++
 apache-mod_cache.conf         |  7 ++--
 apache-mod_deflate.conf       | 40 +++++----------------
 apache-mod_proxy.conf         | 30 ++++++++--------
 apache-mod_userdir.conf       |  1 +
 apache-mpm.conf               | 14 ++++++++
 apache.service                | 12 +++----
 apache.spec                   | 41 +++++++++++++++++++---
 apache.sysconfig              |  2 +-
 12 files changed, 198 insertions(+), 63 deletions(-)
---
diff --git a/apache.spec b/apache.spec
index 7c2baf1..de71b8a 100644
--- a/apache.spec
+++ b/apache.spec
@@ -35,7 +35,7 @@ Summary(ru.UTF-8):	Самый популярный веб-сервер
 Summary(tr.UTF-8):	Lider WWW tarayıcı
 Name:		apache
 Version:	2.4.71
-Release:	1
+Release:	2
 License:	Apache v2.0
 Group:		Networking/Daemons/HTTP
 Source0:	http://www.apache.org/dist/httpd/httpd-%{version}.tar.bz2
@@ -74,6 +74,9 @@ Source31:	%{name}.service
 Source32:	%{name}-mod_http2.conf
 Source33:	%{name}-mod_md.conf
 Source34:	%{name}-mod_dav.tmpfiles
+Source35:	%{name}-htcacheclean.init
+Source36:	%{name}-htcacheclean.service
+Source37:	%{name}-htcacheclean.sysconfig
 Patch0:		%{name}-configdir_skip_backups.patch
 Patch1:		%{name}-layout.patch
 Patch2:		%{name}-suexec.patch
@@ -138,7 +141,6 @@ Requires:	%{name}-mod_rewrite = %{version}-%{release}
 Requires:	%{name}-mod_setenvif = %{version}-%{release}
 Requires:	%{name}-mod_speling = %{version}-%{release}
 Requires:	%{name}-mod_status = %{version}-%{release}
-Requires:	%{name}-mod_userdir = %{version}-%{release}
 Requires:	%{name}-mod_version = %{version}-%{release}
 Requires:	%{name}-tools = %{version}-%{release}
 BuildRoot:	%{tmpdir}/%{name}-%{version}-root-%(id -u -n)
@@ -1005,7 +1007,11 @@ Summary:	Content cache keyed to URIs
 Summary(pl.UTF-8):	Pamięć podręczna wg klucza URI
 Group:		Networking/Daemons/HTTP
 URL:		http://httpd.apache.org/docs/2.4/en/mod/mod_cache.html
+Requires(post,preun):	/sbin/chkconfig
+Requires(post,preun,postun):	systemd-units >= 38
 Requires:	%{name}-base = %{version}-%{release}
+Requires:	rc-scripts
+Requires:	systemd-units >= 38
 Provides:	apache(mod_cache) = %{version}-%{release}
 
 %description mod_cache
@@ -1237,7 +1243,6 @@ Group:		Networking/Daemons/HTTP
 URL:		http://httpd.apache.org/docs/2.4/mod/mod_deflate.html
 Requires:	%{name}-base = %{version}-%{release}
 Requires:	%{name}-mod_filter = %{version}-%{release}
-Requires:	%{name}-mod_headers = %{version}-%{release}
 Provides:	apache(mod_deflate) = %{version}-%{release}
 
 %description mod_deflate
@@ -2896,6 +2901,11 @@ cp -a %{SOURCE29} $RPM_BUILD_ROOT%{_sysconfdir}/vhosts.d/example.net.conf
 cp -p %{SOURCE30} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/%{name}.conf
 cp -p %{SOURCE34} $RPM_BUILD_ROOT%{systemdtmpfilesdir}/%{name}-mod_dav.conf
 
+install -d $RPM_BUILD_ROOT/var/cache/httpd/mod_cache_disk
+install -p %{SOURCE35} $RPM_BUILD_ROOT/etc/rc.d/init.d/htcacheclean
+cp -p %{SOURCE36} $RPM_BUILD_ROOT%{systemdunitdir}/htcacheclean.service
+cp -p %{SOURCE37} $RPM_BUILD_ROOT/etc/sysconfig/htcacheclean
+
 modules="
 	%{?with_bucketeer:bucketeer}
 	access_compat
@@ -3149,9 +3159,28 @@ fi
 %module_scripts mod_brotli
 %module_scripts mod_bucketeer
 %module_scripts mod_buffer
-%module_scripts mod_cache
 %module_scripts mod_case_filter
 %module_scripts mod_case_filter_in
+%post mod_cache
+/sbin/chkconfig --add htcacheclean
+%service htcacheclean restart
+%systemd_post htcacheclean.service
+%module_post
+
+%preun mod_cache
+if [ "$1" = "0" ]; then
+	%service htcacheclean stop
+	/sbin/chkconfig --del htcacheclean
+fi
+%systemd_preun htcacheclean.service
+
+%postun mod_cache
+%module_postun
+%systemd_reload
+
+%triggerpostun mod_cache -- %{name}-mod_cache < 2.4.71-2
+%systemd_trigger htcacheclean.service
+
 %module_scripts mod_cern_meta
 %module_scripts mod_cgi
 %module_scripts mod_cgid
@@ -3491,11 +3520,15 @@ fi
 %files mod_cache
 %defattr(644,root,root,755)
 %attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) %{_sysconfdir}/conf.d/*_mod_cache.conf
+%attr(640,root,root) %config(noreplace) %verify(not md5 mtime size) /etc/sysconfig/htcacheclean
+%attr(754,root,root) /etc/rc.d/init.d/htcacheclean
+%{systemdunitdir}/htcacheclean.service
 %attr(755,root,root) %{_sbindir}/htcacheclean
 %attr(755,root,root) %{_libexecdir}/mod_cache.so
 %attr(755,root,root) %{_libexecdir}/mod_cache_disk.so
 %attr(755,root,root) %{_libexecdir}/mod_cache_socache.so
 %{_mandir}/man8/htcacheclean.8*
+%dir %attr(770,root,http) /var/cache/httpd/mod_cache_disk
 
 %files mod_case_filter
 %defattr(644,root,root,755)
diff --git a/apache-common.conf b/apache-common.conf
index cbd4cee..e0016fe 100644
--- a/apache-common.conf
+++ b/apache-common.conf
@@ -31,7 +31,8 @@ DocumentRoot "/home/services/httpd/html"
 # - backup files from being viewed
 # - PHP's .user.ini
 # - .env files (may contain secrets)
-<FilesMatch  "^(\.ht.*|\.user\.ini|\.env.*|.*~|.*,v)$">
+# - macOS Finder metadata
+<FilesMatch  "^(\.ht.*|\.user\.ini|\.env.*|\.DS_Store|.*~|.*,v)$">
 	<IfModule mod_authz_host.c>
 		Require all denied
 	</IfModule>
@@ -45,7 +46,7 @@ DocumentRoot "/home/services/httpd/html"
 
 # Prevent access to:
 # - version control directories
-<DirectoryMatch "/(\.(svn|git|hg|bzr)|CVS|DS_Store)/?">
+<DirectoryMatch "/(\.(svn|git|hg|bzr)|CVS)(/|$)">
 	<IfModule mod_authz_host.c>
 		Require all denied
 	</IfModule>
diff --git a/apache-htcacheclean.init b/apache-htcacheclean.init
new file mode 100644
index 0000000..2cbd7d6
--- /dev/null
+++ b/apache-htcacheclean.init
@@ -0,0 +1,82 @@
+#!/bin/sh
+#
+# htcacheclean	Apache disk cache cleaner
+#
+# chkconfig:	345 86 14
+# description:	htcacheclean keeps the mod_cache_disk cache below a size limit.
+# processname:	htcacheclean
+# pidfile:	/var/run/httpd/htcacheclean.pid
+# config:	/etc/sysconfig/htcacheclean
+
+# Source function library
+. /etc/rc.d/init.d/functions
+
+# Get service config
+. /etc/sysconfig/htcacheclean
+
+PIDFILE=/var/run/httpd/htcacheclean.pid
+
+start() {
+	if [ -f /var/lock/subsys/htcacheclean ]; then
+		msg_already_running htcacheclean
+		return
+	fi
+
+	msg_starting htcacheclean
+	daemon --user http --pidfile $PIDFILE /usr/sbin/htcacheclean -P $PIDFILE \
+		-d $HTCACHECLEAN_INTERVAL -p $HTCACHECLEAN_PATH -l $HTCACHECLEAN_LIMIT $HTCACHECLEAN_OPTIONS
+	RETVAL=$?
+	[ $RETVAL -eq 0 ] && touch /var/lock/subsys/htcacheclean
+}
+
+stop() {
+	if [ ! -f /var/lock/subsys/htcacheclean ]; then
+		msg_not_running htcacheclean
+		return
+	fi
+
+	msg_stopping htcacheclean
+	killproc --pidfile $PIDFILE htcacheclean
+	rm -f /var/lock/subsys/htcacheclean $PIDFILE
+}
+
+condrestart() {
+	if [ ! -f /var/lock/subsys/htcacheclean ]; then
+		msg_not_running htcacheclean
+		RETVAL=$1
+		return
+	fi
+
+	stop
+	start
+}
+
+RETVAL=0
+# See how we were called.
+case "$1" in
+  start)
+	start
+	;;
+  stop)
+	stop
+	;;
+  restart)
+	stop
+	start
+	;;
+  try-restart)
+	condrestart 0
+	;;
+  force-reload)
+	condrestart 7
+	;;
+  status)
+	status --pidfile $PIDFILE htcacheclean
+	RETVAL=$?
+	;;
+  *)
+	msg_usage "$0 {start|stop|restart|try-restart|force-reload|status}"
+	exit 3
+esac
+
+exit $RETVAL
diff --git a/apache-htcacheclean.service b/apache-htcacheclean.service
new file mode 100644
index 0000000..577f7f7
--- /dev/null
+++ b/apache-htcacheclean.service
@@ -0,0 +1,14 @@
+[Unit]
+Description=Disk cache cleaner for the Apache HTTP Server
+After=httpd.service
+
+[Service]
+Type=forking
+User=http
+EnvironmentFile=/etc/sysconfig/htcacheclean
+PIDFile=/run/httpd/htcacheclean.pid
+ExecStart=/usr/sbin/htcacheclean -P /run/httpd/htcacheclean.pid -d $HTCACHECLEAN_INTERVAL -p $HTCACHECLEAN_PATH -l $HTCACHECLEAN_LIMIT $HTCACHECLEAN_OPTIONS
+PrivateTmp=true
+
+[Install]
+WantedBy=multi-user.target
diff --git a/apache-htcacheclean.sysconfig b/apache-htcacheclean.sysconfig
new file mode 100644
index 0000000..c04027b
--- /dev/null
+++ b/apache-htcacheclean.sysconfig
@@ -0,0 +1,13 @@
+# Settings for htcacheclean, the mod_cache_disk cleaner, see htcacheclean(8)
+
+# Cache directory, the same as CacheRoot in /etc/httpd/conf.d/01_mod_cache.conf
+HTCACHECLEAN_PATH="/var/cache/httpd/mod_cache_disk"
+
+# Disk space limit, with K, M or G suffix
+HTCACHECLEAN_LIMIT="1G"
+
+# Minutes between cleaning runs
+HTCACHECLEAN_INTERVAL="15"
+
+# Other options: -n runs at low priority, -t removes emptied directories
+HTCACHECLEAN_OPTIONS="-n -t"
diff --git a/apache-mod_cache.conf b/apache-mod_cache.conf
index b6a3250..6fcc2f5 100644
--- a/apache-mod_cache.conf
+++ b/apache-mod_cache.conf
@@ -12,10 +12,11 @@ LoadModule cache_module	modules/mod_cache.so
 	CacheIgnoreHeaders Set-Cookie
 
 	<IfModule mod_cache_disk.c>
-		CacheRoot "/var/cache/httpd"
+		# size is kept down by the htcacheclean service, see /etc/sysconfig/htcacheclean
+		CacheRoot "/var/cache/httpd/mod_cache_disk"
 		CacheEnable disk /
-		CacheDirLevels 5
-		CacheDirLength 3
+		CacheDirLevels 2
+		CacheDirLength 1
 
 #		CacheDefaultExpire 3600
 #		CacheMinExpire 3600
diff --git a/apache-mod_deflate.conf b/apache-mod_deflate.conf
index 9428679..3364ef9 100644
--- a/apache-mod_deflate.conf
+++ b/apache-mod_deflate.conf
@@ -1,34 +1,10 @@
 LoadModule deflate_module		modules/mod_deflate.so
 
-# Safe but working settings - compress only that types:
-AddOutputFilterByType DEFLATE application/javascript application/x-javascript text/javascript
-AddOutputFilterByType DEFLATE application/x-httpd-php
-AddOutputFilterByType DEFLATE application/xhtml+xml
-AddOutputFilterByType DEFLATE image/svg+xml
-AddOutputFilterByType DEFLATE text/css
-AddOutputFilterByType DEFLATE text/html 
-AddOutputFilterByType DEFLATE text/plain
-AddOutputFilterByType DEFLATE text/xml
-
-# Compress all and exclude only few things - may cause some problems:
-#SetOutputFilter DEFLATE
-
-<IfModule mod_setenvif.c>
-	# Netscape 4.x has some problems...
-	BrowserMatch ^Mozilla/4 gzip-only-text/html
-
-	# Netscape 4.06-4.08 have some more problems
-	BrowserMatch ^Mozilla/4\.0[678] no-gzip
-
-	# MSIE masquerades as Netscape, but it is fine
-	BrowserMatch \bMSIE !no-gzip !gzip-only-text/html
-
-	SetEnvIfNoCase Request_URI \.(?:gif|jpe?g|png)$ no-gzip dont-vary
-	SetEnvIfNoCase Request_URI \.pdf$ no-gzip dont-vary
-	SetEnvIfNoCase Request_URI \.(?:exe|t?gz|zip|bz2|sit|rar|iso)$ no-gzip dont-vary
-</IfModule>
-
-<IfModule mod_headers.c>
-	# Make sure proxies don't deliver the wrong content
-	Header append Vary Accept-Encoding env=!dont-vary
-</IfModule>
+# Compress text-like types only, other formats are already compressed.
+# mod_deflate adds "Vary: Accept-Encoding" to these responses itself.
+AddOutputFilterByType DEFLATE text/html text/plain text/xml text/css text/csv text/markdown
+AddOutputFilterByType DEFLATE text/javascript application/javascript application/x-javascript
+AddOutputFilterByType DEFLATE application/json application/ld+json application/manifest+json
+AddOutputFilterByType DEFLATE application/xml application/xhtml+xml application/rss+xml application/atom+xml
+AddOutputFilterByType DEFLATE image/svg+xml image/x-icon image/vnd.microsoft.icon
+AddOutputFilterByType DEFLATE font/ttf font/otf application/vnd.ms-fontobject application/wasm
diff --git a/apache-mod_proxy.conf b/apache-mod_proxy.conf
index 5dcd0dd..01136cf 100644
--- a/apache-mod_proxy.conf
+++ b/apache-mod_proxy.conf
@@ -22,22 +22,22 @@ LoadModule proxy_module			 modules/mod_proxy.so
 # enable the proxy server:
 #
 <IfModule proxy_module>
+# Forward proxy, limited to local clients.
 ProxyRequests On
-#
-#
-# This prevents spammers from using apache as a relay by posting to
-# http://victim:25/ and sending raw data.
-#
 <Proxy *>
-	Require all denied
-#	Require host .your-domain.com
-	<IfModule mod_access_compat.c>
-            <IfModule !mod_authz_host.c>
-		Order deny,allow
-		Deny from all
-#		Allow from .your-domain.com
-            </IfModule>
-	</IfModule>
+	# Forward proxy requests are the ones not in origin-form ("GET /path"),
+	# ProxyPass and RewriteRule [P] reverse proxying stays unrestricted.
+	<If "%{THE_REQUEST} !~ m#^\S+\s+/#">
+		Require local
+#		Require host .your-domain.com
+		<IfModule mod_access_compat.c>
+		    <IfModule !mod_authz_host.c>
+			Order deny,allow
+			Deny from all
+			Allow from 127.0.0.1 ::1
+		    </IfModule>
+		</IfModule>
+	</If>
 </Proxy>
 
 # enable local fcgi proxy request, e.x for php-fpm
@@ -50,7 +50,7 @@ ProxyRequests On
 # ("Full" adds the server version; "Block" removes all outgoing Via: headers)
 # Set to one of: Off | On | Full | Block
 #
-ProxyVia On
+#ProxyVia On
 
 # To enable the cache as well, see mod_cache.conf
 
diff --git a/apache-mod_userdir.conf b/apache-mod_userdir.conf
index c02bb88..3873993 100644
--- a/apache-mod_userdir.conf
+++ b/apache-mod_userdir.conf
@@ -11,6 +11,7 @@ LoadModule userdir_module	   modules/mod_userdir.so
 # the default access control for these directories, as in the example below.
 #
 UserDir public_html
+UserDir disabled root
 
 #
 # Control access to UserDir directories.  The following is an example
diff --git a/apache-mpm.conf b/apache-mpm.conf
index 5a1b75c..2fdad26 100644
--- a/apache-mpm.conf
+++ b/apache-mpm.conf
@@ -59,3 +59,17 @@ PidFile /var/run/httpd.pid
 	ThreadsPerChild	 	25
 	MaxConnectionsPerChild	0
 </IfModule>
+
+# event MPM
+# Same as worker, but keep-alive and finishing connections do not hold a thread.
+# ServerLimit: process slots; keep it above MaxRequestWorkers / ThreadsPerChild,
+#   gracefully finishing processes keep their slots after reload or scale-down
+<IfModule mpm_event_module>
+	StartServers		 3
+	ServerLimit		32
+	MaxRequestWorkers	400
+	MinSpareThreads		75
+	MaxSpareThreads		250
+	ThreadsPerChild		25
+	MaxConnectionsPerChild	0
+</IfModule>
diff --git a/apache.service b/apache.service
index 26fee96..3ba14f3 100644
--- a/apache.service
+++ b/apache.service
@@ -1,17 +1,17 @@
 [Unit]
 Description=The Apache HTTP Server
-After=syslog.target network.target remote-fs.target nss-lookup.target
+After=network.target remote-fs.target nss-lookup.target
 
 [Service]
-Type=forking
-PIDFile=/var/run/httpd.pid
+# READY comes from mod_systemd (00_mod_systemd.conf in apache-base)
+Type=notify
 EnvironmentFile=/etc/sysconfig/httpd
-ExecStartPre=/bin/sh -c '/usr/bin/test -f "${HTTPD_CONF}" -o -d "${HTTPD_CONF}" || (echo "${HTTPD_CONF} is not file or directory"; exit 1)'
 ExecStartPre=/usr/sbin/httpd -f ${HTTPD_CONF} $HTTPD_OPTS -t
-ExecStart=/usr/sbin/httpd -f ${HTTPD_CONF} $HTTPD_OPTS -k start
+ExecStart=/usr/sbin/httpd -f ${HTTPD_CONF} $HTTPD_OPTS -DFOREGROUND
 ExecReload=/usr/sbin/httpd -f ${HTTPD_CONF} $HTTPD_OPTS -t
 ExecReload=/usr/sbin/httpd -f ${HTTPD_CONF} $HTTPD_OPTS -k graceful
-ExecStop=/usr/sbin/httpd -f ${HTTPD_CONF} $HTTPD_OPTS -k stop
+# SIGTERM to the parent only, it stops its children; SIGKILL leftovers on timeout
+KillMode=mixed
 PrivateTmp=true
 
 [Install]
diff --git a/apache.sysconfig b/apache.sysconfig
index 1a719d6..73a1a38 100644
--- a/apache.sysconfig
+++ b/apache.sysconfig
@@ -1,6 +1,6 @@
 # Customized settings for Apache
 
-# Nice level for apache
+# Nice level for apache (SysV init only, under systemd use Nice= in a drop-in)
 SERVICE_RUN_NICE_LEVEL="+5"
 
 # config dir/file path.
================================================================

---- gitweb:

http://git.pld-linux.org/gitweb.cgi/packages/apache.git/commitdiff/a17f043f7aac211d70ecd1a5c939252dda583dcf



More information about the pld-cvs-commit mailing list