Wednesday, 25 April 2018

how to configure your website with ssl

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

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

# www.yourdomain.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 you can use are debug, info, notice, warn, error, crit,
# alert, emerg.
LogLevel warn

CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

# detect 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

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

CustomLog ${APACHE_LOG_DIR}/access.log combined

</VirtualHost>

Featured post

How to create dynamic schema in mongodb

Sometime what we need in our application is to create mongodb schema for collection and some of our collection schema are same but names are...

Popular Posts