Magento – How to use cloudflare free SSL with Magento

magento-1.9ssl

I use flexible SSL in cloudflare and go to https of my magento site. The site loads but the theme is not loaded. Checked the source code and realize the css and js was loaded in http instead of https. I found an article from cloudflare and realized it is due to connection from cloudflare to web server is in http thus css and js src is in http.

I try to set the Base Link URL, Base Skin URL, Base Media URL and Base JavaScript URL started with //domain.com so that it will load assetts in same protocol as the main page in magento admin but it does not allow me to save. So I edit the core_config_data table directly and set Base Link URL, Base Skin URL, Base Media URL and Base JavaScript URL to started with //domain.com. Clear the /var/cache and /var/session and the site loaded nicely.

However I'm not sure what I did is correct way to using cloudflare free ssl with Magento, and what will be the consequences of this way? Anyone with experience using cloudflare free ssl on magento?

Best Answer

SSL is managed from the web server (apache, nginx, etc..). Magento has only to know if the domain has a ssl certificate. So, once you changed the fields like below, in core_config_data table:

web/unsecure/base_url => http://www.yourdomain.com
web/secure/base_url => https://www.yourdomain.com

magento will run perfectly! Of course, you have to set YES in "Use Secure URLs" in Admin. Other fields can stay like this:

web/unsecure/base_link_url => {{unsecure_base_url}}
web/unsecure/base_skin_url => {{unsecure_base_url}}skin/
web/unsecure/base_media_url => {{unsecure_base_url}}media/
web/unsecure/base_js_url => {{unsecure_base_url}}js/
web/secure/base_link_url => {{secure_base_url}}
web/secure/base_skin_url => {{secure_base_url}}skin/
web/secure/base_media_url   => {{secure_base_url}}media/
web/secure/base_js_url => {{secure_base_url}}js/
Related Topic