Apache SSL Config

In this article i'll show you how to configure your website with ssl. It is also captured the user who go directly mydomain.com without www. Please note that this requires two sets of ssl certificates, unless you have wildcard ones.

In ubuntu 16.04 the file location is /etc/apache2/sites-available/default-ssl.conf  and enabled by running a2ensite default-ssl.conf . Also, don't forget to enable ssl with sudo a2enmod ssl.

# www.mydomain.com
<VirtualHost *:443>
    ServerName www.mydomain.com

    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/www.mydomain.com/cert.pem
    SSLCertificateKeyFile /etc/apache2/ssl/www.mydomain.com/private.pem
    SSLCertificateChainFile /etc/apache2/ssl/www.mydomain.com/chain.pem

    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/my-site/public_html
    <Directory /var/www/my-site/public_html/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        allow from all
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

# capture users going to mydomain.com without the www.
<VirtualHost *:443>
    ServerName mydomain.com

    SSLEngine on
    SSLCertificateFile /etc/apache2/ssl/mydomain.com/cert.pem
    SSLCertificateKeyFile /etc/apache2/ssl/mydomain.com/private.pem
    SSLCertificateChainFile /etc/apache2/ssl/mydomain.com/chain.pem

    ServerAdmin webmaster@localhost

    DocumentRoot /var/www/my-site/public_html
    <Directory /var/www/my-site/public_html/>
        Options Indexes FollowSymLinks
        AllowOverride All
        Order allow,deny
        allow from all
        Require all granted
    </Directory>

    ErrorLog ${APACHE_LOG_DIR}/error.log

    # Possible values include: debug, info, notice, warn, error, crit,
    # alert, emerg.
    LogLevel warn

    CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Download the eBook of react js for beginners

ReactJS basically is an open-source JavaScript library which is used for building user interfaces specifically for single page applications...

Popular