cancel
Showing results for 
Search instead for 
Did you mean: 

'Superimpose' a FQDN infront of a fixed FQDN with Stingray?

SOLVED
Highlighted
New Contributor

'Superimpose' a FQDN infront of a fixed FQDN with Stingray?

I'm sure this is possible with Stingray, just not 100% if it is, or how complicated it would be...

If you have an e-commerce site, say https://www.shop.com and for some daft reason, the e-commerce software fixes you to this one single domain (not a license restriction, but a functionality one) - and we wanted to be able to 'superimpose' www.shop.de so that this FQDN 'worked' in front of the website - by running response and request re-writing on the Stingray - would this work - would this allow us to use both .com and .de domains on this single site?

So requests for www.shop.de would land on the Stingray, which would re-write the requests through to the web server actually as www.shop.com even though the user sees www.shop.de in their browser. The response from the webserver would of course still come back from www.shop.com so we would need to also e-write this back as shop.de, however I suspect this element would be far tricker, as we would actually need to re-write links in the <BODY> also.

As long as the Stingray is doing SSL decrypt, would this work in theory? Any examples / tips to help us experiment?

I know the language etc would all be the same, it's just a .de domain needs to present in the browser!

The other route is to create a site for each domain, etc...

Cheers,


Jeff

3 REPLIES
Frequent Contributor

Re: 'Superimpose' a FQDN infront of a fixed FQDN with Stingray?

Should be easy to achieve... the easiest solution would be to inspect the body data and strip out any 'http://www.shop.com/", so you end up with relative links (/products) rather than full ones (http://www.shop.com/products).

Then, your customers web browsers will just assume that the domain has not changed, so they will continue to use shop.com or shop.de as appropriate.

Also, check out the location and cookie rewrite settings in the connection management part of the Stingray virtual server.  If your website tries to redirect your clients to a particular domain, or pin a cookie to that domain, we can fix that too

regards

Owen

New Contributor

Re: 'Superimpose' a FQDN infront of a fixed FQDN with Stingray?

OK so I *sort* of got this working, although as you will see - it's kind of messy.

I checked the cookies and it does not seem like there is anything going on there.

First of all I stuck a simple http.setheader rule in to detect the 'de' domain and replace it with the only domain that is supposed to work - the .co.uk one - this is a request rule:


if( string.contains( http.getheader( "host" ), "website.de" ) ){


        http.setheader( "host", "www.website.co.uk" );


}



So this just tinkers with the host header going from the Stingray to the back end server. I think this is OK.

Next, is where I kind of go off the rails. I need to tinker with the response that comes back from the webserver to the client, and basically strip the domain out whatever it is....


# settings


$domainStrip = "";


$domainUK = "www.website.co.uk";


# end settings


# rewrite all links to strip domain




$response = http.getResponseBody();


if( string.contains( $response, $domainUK ) ) {


$response = string.regexsub( $response , $domainUK, $domainStrip, "g" );



}




http.setResponseBody( $response );


This very nearly works, however for some reason, some of the sites js and css files don't come down from the new FQDN, but instead http://path/to/css rather than http://www.website.de/path/to/css. If I substitute the stripped domain "" setting for the actual DE domain - then it all works wonderfully, but of course doing this, everything gets written as DE which is not what we want to achieve!!!


Looking at responses coming back in firebug I can see the all the offending css/js are missing a forward slash - I'm sure this has something to do with it. Working css/js objects show as /path/to/css - when the non-working ones show as path/to/css.

Why some css/js are behaving differently - not really sure.


Dodgy coding!?!?

(most likely mine!)


Jeff

Frequent Contributor

Re: Re: 'Superimpose' a FQDN infront of a fixed FQDN with Stingray?

Hi Jeff,

Try stripping the entire http://www.site.co.uk from the start of the URL.  This has the advantage that you're less likely to modify content by mistake (for example, if the text of your document says "visit www.site.co.uk", you don't want to remove the domain from that text).

The following ought to do the trick:


$body = http.getResponseBody();


$newbody = string.replaceAll( $body, "http://www.site.co.uk", "" );



if( $newbody != $body ) http.setResponseBody( $newbody );


You want each URL to begin with a '/'; if a web client encounters a URL that looks like "/path/to/resource.html", it will deduce that the protocol, port and domain/host should be the same as the referring document.

One recommendation - take a look at the source of the document as well as using firebug.  The source is the definitive record of what you have changed.

Hope that this helps

Owen