Deactivate default ports of systemd socket activation
You can list the files being used by systemd for the socket by using:
$ systemctl cat httpd.socket
and on my system this shows (some lines removed to keep it short):
# /usr/lib/systemd/system/httpd.socket
[Unit]
Description=Apache httpd Server Socket
[Socket]
ListenStream=80
[Install]
WantedBy=sockets.target
# /usr/lib/systemd/system/httpd.socket.d/10-listen443.conf
[Socket]
ListenStream=443
You can see that 2 named files are used (on my system) to listen on ports 80 and 443. You can use sudo systemctl edit httpd.socket
to add more configuration. To actually cancel an existing configuration, you need to use the standard systemd method of entering an empty value for the keyword, i.e. in this case: ListenStream=
, followed by any wanted additional values:
[Socket]
# cancel existing port 80 (and 443)
ListenStream=
ListenStream=8001
ListenStream=8002
ListenStream=8003
man systemd.syntax
(or man systemd.unit
in older versions) says
Various settings are allowed to be specified more than once, in which case the interpretation depends on the setting. Often, multiple settings form a list, and setting to an empty value "resets", which means that previous assignments are ignored.