How add SSL/443 to Apache server without virtual host?
Solution 1:
By default, in CentOS, there is a file used by Apache/httpd located at /etc/httpd/conf.d/ssl.conf
. This file is read in as a configuration by Apache along with the "httpd.conf" file and anything in it takes precedence over settings in httpd.conf
.
That file (again by default) contains a Listen 443
directive. You cannot call that directive twice (as it will say it's already been bound to that port), so that caused the conflict. After removing that, it works.
Solution 2:
In case anybody stumbles over this question in 2017...
There is no need to edit httpd.conf
since ssl.conf
contains all the directives we need:
# When we also provide SSL we have to listen to the
# the HTTPS port in addition.
#
Listen 443 https
...
# SSL Engine Switch:
# Enable/Disable SSL for this virtual host.
SSLEngine on
And of course the paths to the certs:
SSLCertificateFile /etc/pki/tls/certs/<mycert>.crt
SSLCertificateKeyFile /etc/pki/tls/private/<mykey>.key
In other words, it is enough to add the information in ssl.conf
and the restart the httpd
service. Of course, this only works if this (the last) line:
# Load config files in the "/etc/httpd/conf.d" directory, if any.
IncludeOptional conf.d/*.conf
...is uncommented as per above in the file httpd.conf
, which it is in a default installation.
System info:
cat /etc/redhat-release
Red Hat Enterprise Linux Server release 7.3 (Maipo)