Search code examples
azure

installing an SSL on Azure ubuntu web server


I have been trying to install an SSL Certificate on an Ubuntu Server running on a VPS.


Solution

  • He is what I did to resolve the issue. 1. I created a new endpoint (HTTPS - port 443) from my Microsoft Azure portal

    On my Ubuntu VM terminal, I did the following. To enable the SSL module in Apache2 you issue the command below

    sudo a2enmod ssl
    

    The you need to enable the site that would using the SSL

    sudo a2ensite default-ssl
    

    The directories /etc/ssl/certs and /etc/ssl/private are the default locations. If you install the certificate and key in another directory make sure to change SSLCertificateFile and SSLCertificateKeyFile appropriately. Add the following to your default-ssl file.

        SSLEngine on
        SSLCertificateKeyFile /etc/sslmate/example.com.key
        SSLCertificateFile /etc/sslmate/example.com.crt
        SSLCertificateChainFile /etc/sslmate/example.comchain.crt
    
    
    SSLProtocol all -SSLv2 -SSLv3
    SSLCipherSuite ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA
    SSLHonorCipherOrder on
    SSLCompression off
    

    now configured for HTTPS, restart the apache2 service to enable the new settings:

    sudo service apache2 restart
    

    You might want to redirect all your HTTP request to HTTPS, add the code below to your virtualHost file listening to port 80. It will redirect all HTTP request to the HTTPS (https://example.com)

    <VirtualHost _default_:80>
     RewriteEngine On
         RewriteRule /.* https://example.com/ [R]
    
    </VirtualHost>