Monday, October 21, 2013

Redirect all http request to https

I got a request to redirect all http request in apache to https

Backup current httpd.conf file

Enable mod_rewitre

Add the following line in httpd.conf just below

<Directory "/var/www/html"> (In my case only one domain is hosted in that server)
RewriteEngine On
RewriteCond %{HTTPS} off
RewriteRule (.*) https://%{HTTP_HOST}%{REQUEST_URI} 

Restart httpd

How to install and configure SSL from godaddy in Centos6

First we need to generate CSR

openssl req -new -newkey rsa:2048 -nodes -keyout domainname.key -out domainname.csr

Rename domainname.key and .csr with your domain name

Copy the domainanme.csr and upload to godaddy page for certifiying.

It will take couple of days to get authorized and you will get a mail notification. Once this process finished login to your godaddy account and download the zip formatted certificates.

Upload the to the server.

Include ssl.conf in conf.d

vi /etc/httpd/conf.d/ssl.conf

SSLCertificateFile /etc/pki/tls/certs/5fjr5j9dw2f.crt (I get from godaddy)
SSLCertificateKeyFile /etc/pki/tls/private/domainname.key (I get intially from openssl command)
SSLCertificateChainFile /etc/pki/tls/certs/gd_bundle.crt (I get from godaddy)

Restart httpds