SSL & CSS protocols when using a load balanced web farm

When using SSL with a load balancer and sending a non HTTPS request to the other nodes within the web farm, it’s possible that src: url() link in CSS style sheets and the style sheet itself, will be rendered under both HTTP and HTTPS protocols. 
This behavior will cause IE and Firefox to issue a mixed content block warning and not load the images or style sheet.  For example:

Stylesheet definition:
@class {
           src: url('/media/SomeImage.jpg');

Gets rendered as:
@class {
           src: url('');

In order to resolve these issues, you can take the following actions.  

Suggestion 1:  The GetResource file is called to load the CSS style sheets when the setting in Site Manager -> Settings -> System -> Performance -> Resources -> Allow CSS minification is checked.  If you were to disable this setting, the call would instead be made from the GetCSS.aspx which may resolve the issue, but of course you would lose the minification of CSS.

 Suggestion 2: Is to modify the GetResource file directly from the ~\App_Code\CMSPages\GetResource.ashx.cs file (line 1237):

// result.Data = HTMLHelper.ResolveCSSClientUrls(result.Data, URLHelper.GetAbsoluteUrl("~/CMSPages/GetResource.ashx"));

And simply comment this line out which should prevent the absolute URL from being loaded for the CSS style sheet.  Of course this approach could get overridden during a hotfix/upgrade, so you would need to make a note or at least remember you have made this change.

See also:
Indirect SSL

Applies to: Kentico CMS 7.x
Share this article on   LinkedIn

Martin Danko

Let me guide you on your journey of success. I will show you how to optimize your content production with Kentico Draft. Check out