Skip to content

A free open source IT asset/license management system

Fixed #19636 - Added sed rewrite for Apache non-standard ports

snipeb546d6e2c596
diff --git a/docker/column-statistics.cnf b/docker/column-statistics.cnf
index e3bb308082..375f8c233e 100644
--- a/docker/column-statistics.cnf
+++ b/docker/column-statistics.cnf
@@ -1,2 +1,7 @@
[mysqldump]
-column-statistics=0
+# `loose-` prefix: unknown-variable error becomes a warning, so this file is
+# safe to ship to both mysqldump (Oracle MySQL 8.0 client needs
+# column-statistics=0 to dump an older server without blowing up on the
+# information_schema.column_statistics query) and mariadb-dump (which
+# doesn't know about the variable at all).
+loose-column-statistics=0
diff --git a/docker/startup.sh b/docker/startup.sh
index 3ac34ecf90..0f7d506fb9 100644
--- a/docker/startup.sh
+++ b/docker/startup.sh
@@ -130,6 +130,27 @@ then
sed -i "s/^LimitRequestFields.*/LimitRequestFields ${APACHE_LIMIT_REQUEST_FIELDS}/" /etc/apache2/conf-available/limits.conf
fi
+# Apache listening ports. Rootless container runtimes can't bind
+# privileged ports (<1024) even inside the container, so expose both
+# ports as env vars. Defaults preserve the historical 80/443
+# Port substitution happens in both ports.conf (Listen directive)
+# and the VirtualHost conf so Apache's module-side bind and the vhost match.
+# sed with --follow-symlinks because a2ensite symlinks 001-default-ssl.conf
+# from sites-available into sites-enabled.
+if [ -v "APACHE_HTTP_PORT" ] && [ "$APACHE_HTTP_PORT" != "80" ]
+then
+ echo "Changing Apache HTTP port to ${APACHE_HTTP_PORT}"
+ sed -i --follow-symlinks -E "s/^Listen\s+80\b/Listen ${APACHE_HTTP_PORT}/" /etc/apache2/ports.conf
+ sed -i --follow-symlinks -E "s/<VirtualHost\s+\*:80>/<VirtualHost *:${APACHE_HTTP_PORT}>/" /etc/apache2/sites-enabled/000-default.conf
+fi
+
+if [ -v "APACHE_HTTPS_PORT" ] && [ "$APACHE_HTTPS_PORT" != "443" ]
+then
+ echo "Changing Apache HTTPS port to ${APACHE_HTTPS_PORT}"
+ sed -i --follow-symlinks -E "s/^(\s*)Listen\s+443\b/\1Listen ${APACHE_HTTPS_PORT}/" /etc/apache2/ports.conf
+ sed -i --follow-symlinks -E "s/<VirtualHost\s+_default_:443>/<VirtualHost _default_:${APACHE_HTTPS_PORT}>/" /etc/apache2/sites-available/001-default-ssl.conf
+fi
+
# If the Oauth DB files are not present copy the vendor files over to the db migrations
if [ ! -f "/var/www/html/database/migrations/*create_oauth*" ]
then
diff --git a/docker/startup_alpine.sh b/docker/startup_alpine.sh
index 55943dd683..4f359a88ad 100644
--- a/docker/startup_alpine.sh
+++ b/docker/startup_alpine.sh
@@ -114,6 +114,20 @@ then
sed -i "s/^LimitRequestFields.*/LimitRequestFields ${APACHE_LIMIT_REQUEST_FIELDS}/" /etc/apache2/conf.d/limits.conf
fi
+# Apache listening port. Rootless container runtimes can't bind
+# privileged ports (<1024) even inside the container, so expose the
+# port as an env var. Default preserves the historical 80
+# The Alpine image doesn't ship an in-container SSL config, so only HTTP is
+# handled.
+# Users running SSL on this image use their own vhost and can bind
+# whatever port they want there.
+if [ -v "APACHE_HTTP_PORT" ] && [ "$APACHE_HTTP_PORT" != "80" ]
+then
+ echo "Changing Apache HTTP port to ${APACHE_HTTP_PORT}"
+ sed -i -E "s/^Listen\s+80\b/Listen ${APACHE_HTTP_PORT}/" /etc/apache2/httpd.conf
+ sed -i -E "s/<VirtualHost\s+\*:80>/<VirtualHost *:${APACHE_HTTP_PORT}>/" /etc/apache2/conf.d/default.conf
+fi
+
# If the Oauth DB files are not present copy the vendor files over to the db migrations
if [ ! -f "/var/www/html/database/migrations/*create_oauth*" ]
then