Tuesday, January 20, 2015

How add SSL/443 to Apache server without virtual host?



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?


Answer



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.


No comments:

Post a Comment

linux - How to SSH to ec2 instance in VPC private subnet via NAT server

I have created a VPC in aws with a public subnet and a private subnet. The private subnet does not have direct access to external network. S...