Issues With Magento and CloudFlare SSL HTTPS

I ran into this weird issue when trying to implement CloudFlare on a Magento 1.7.0.2.

The SSL setup is right with CloudFlare, however, every time the site tries https protocol (during checkout/admin area), a SSL redirect loop occurs.

The problem can be solved by adding the following line in .htaccess

############################################
## FOR NGINX, LIGHTTPD, VARNISH OR ANY OTHER REVERSE PROXY TO APACHE
SetEnvIf X-Forwarded-Proto https HTTPS=on

http://www.wecode.com.au/magento/cloudflare-magento-ssl-redirect-loop/