On an Apache Server (2.4.37) running on CentOS 8, there should be a redirection of HTTP traffic on port 8765 to the default https port. Therefore, I am trying to make the server listen to port 8765 in order to set up a virtual host which listens to this port. But it fails already here.
When I just add the line
Listen 8765 to line 4 of a conf file in
/etc/httpd/conf.d/ and restart apache, there is the following error:
AH00526: Syntax error on line 4 of /etc/httpd/conf.d/redirect-8765.conf: Systemd socket activation is used, but this port is not configured in systemd
(Contrary to the error message, this is arguably not a syntax error, as the problem lies with the systemd port configuration.)
Looking into the manpage of
httpd.socket(8), I have found the following instructions:
The httpd listener configuration must exactly match the ListenStream options configured for the httpd.socket unit. (…) If additional Listen directives are added to the httpd configuration, corresponding ListenStream options should be added via drop-in files, for example via systemctl edit httpd.socket.
There was a drop-in file for ssl (called
10-listen443.conf) at the location
/usr/lib/systemd/system/httpd.socket.d/, where I wrote another file called
20-redir8765.conf with the following contents:
This did not solve anything, so I tried to execute, as per the manpage,
systemctl edit httpd.socket, which edited the file
/etc/systemd/system/httpd.socket.d/override.conf. There, I have inserted the same lines as above. This also lead to the same error message, but removing the
Listen directive from the httpd configuration file (not the systemd socket config), and restarting the server, the server status indicated the following:
httpd.socket - Apache httpd Server Socket Loaded: loaded (/usr/lib/systemd/system/httpd.socket; enabled; vendor preset: disabled) Drop-In: /usr/lib/systemd/system/httpd.socket.d └─10-listen443.conf, 20-redir8765.conf /etc/systemd/system/httpd.socket.d └─override.conf Active: active (running) since Fri 2020-09-11 14:18:09 UTC; 2h 2min ago Docs: man:httpd.socket(8) Listen: (::):80 (Stream) (::):443 (Stream) (::):8765 (Stream) (::):8765 (Stream) CGroup: /system.slice/httpd.socket
Assuming that now the ports are activated via systemd, I re-inserted the
Listen directive. But then, the same initial error arised.
Under these circumstances, how can I add a VirtualHost which listens to a port?