How do I use SSL on multiple ports?

July 18, 2016 273 views
Apache Nginx Node.js Security Ubuntu

Hello, I followed the docs on how to install an SSL but I have multiple ports that run on my droplet. I'd actually like to not be limited by which port SSL runs on. Is this possible?

2 Answers

First you need to tell apache to listen on multiple ports. You can do that by editing the /etc/apache2/ports.conf

Listen 80
<IfModule ssl_module>
        Listen 443
        Listen 444
        Listen 446

And your virtualhost file should look like this with the port number.

<VirtualHost *:446>
        ServerAdmin webmaster@localhost
        DocumentRoot /var/www/html

        ErrorLog ${APACHE_LOG_DIR}/error.log
        CustomLog ${APACHE_LOG_DIR}/access.log combined

        SSLEngine on
        SSLCertificateFile      /etc/ssl/certs/ssl-cert-snakeoil.pem
        SSLCertificateKeyFile /etc/ssl/private/ssl-cert-snakeoil.key

Thanks for the answer, but I forgot to mention I was using nginx instead of Apache. How would this change, since I assume I'd be editing the /etc/nginx/sites-available/default file, right?

Have another answer? Share your knowledge.