How do I use SSL on multiple ports?

Posted July 18, 2016 37.3k views

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?

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Submit an Answer
3 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

Is it possible to configure “https” in same domain for multiple ports? Like

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?