I have an apache server set up on CentOS. I am trying to add SSL. I was able to create the certificate and keys and then updated /etc/httpd/conf.d/ssl.conf
to have the following configurations:
/etc/httpd/conf.d/ssl.conf
#Where I put my cert
SSLCertificateFile /etc/pki/tls/certs/ca.crt
#where I put my key
SSLCertificateKeyFile /etc/pki/tls/private/ca.key
Then I updated /etc/httpd/conf/httpd.conf
:
/etc/httpd/conf/httpd.conf
Listen 443
SSLEngine on
SSLCertificateFile /etc/pki/tls/certs/ca.crt
SSLCertificateKeyFile /etc/pki/tls/private/ca.key
Then I ran service httpd restart
and I get the error:
Stopping httpd: [OK]
Starting httpd: (98)Address already in use: make_sock: could not bind to address [::]:443
[OK]
What do I need to do to enable SSL?
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 inhttpd.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.In case anybody stumbles over this question in 2017...
There is no need to edit
httpd.conf
sincessl.conf
contains all the directives we need:...
And of course the paths to the certs:
In other words, it is enough to add the information in
ssl.conf
and the restart thehttpd
service. Of course, this only works if this (the last) line:...is uncommented as per above in the file
httpd.conf
, which it is in a default installation.System info:
On Debian bases Systems or usually on generally other
Create
/etc/apache2/conf-available/default-ssl.conf
This Works out of the Box, in case you want to use the default page i.e. for Reverse-Proxy with NGINX or Other.
Its not limited to a VHOST.
Additional Information
It will not Produce an error due the fact, it only works when Mod-SSL is enabled.
Remind to restart Apache
This works for me since ages.