0
votes

We have a load balancer set up that forwards requests to two apache web servers. Currently we set up an SSL certificate on the load balancer side, but the problem is that after the load balancer the requests are still forwarded as HTTP, and we use the request to generate absolute url's to our CSS and JS assets. (Implemented with java portlets)

So when a user enters over HTTPS he still has absolute links via HTTP, and therefore the styling breaks.

Basically we want to generate links depending on the request protocol, but we always get HTTP on our side. The problem is that our access to the load balancer is limited. (client has control)

Can anyone suggest some kind of solution that will help us determine the request type even if it's forwarded using plain HTTP? (Send headers to Apache from the load balancer?)

1

1 Answers

1
votes

below codes would help you, we are facing the same issue with you, we just check if the request is http or https,and then using different configuration.

var protocol = (HtmlPage.Window.GetProperty("location") as ScriptObject).GetProperty("protocol").ToString().Replace(":", String.Empty);

// root path will have the value like: https://am1stg-i.serviceportal.hp.com/gsda/home/
var rootPath = HtmlPage.Window.GetProperty("rootPath").ToString();

//var configuration = protocol == "http" ? "teamcollaborationBinding_TeamCollaborationService" : "teamcollaborationBinding_TeamCollaborationServiceHttps";

var isHttps = string.Equals("https", protocol, StringComparison.InvariantCultureIgnoreCase);

var address = new EndpointAddress(rootPath + "TeamCollaborationService.svc");

//serviceClient = new TeamCollaborationServiceClient("teamcollaborationBinding_TeamCollaborationService", address);
//serviceClient = new TeamCollaborationServiceClient();

serviceClient = new TeamCollaborationServiceClient(isHttps ? "teamcollaborationBinding_TeamCollaborationService" : "teamcollaborationBinding_TeamCollaborationService_http", address);