How do I use SSL on multiple ports?

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?

Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

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.

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?