Hi Folks,
First timer on splash and writing my own traffic script infact so go easy on me, this will be very much sucking eggs for most people i guess.
We have a requirement to point any traffic coming in to the URL http://www.suckeggs.com/scotland to be pointed to a different internal server whilst all other traffic for http://www.suckeggs.com and subsections of that site will remain pointing to the same backend pool.
Thanks
Rob
Solved! Go to Solution.
Hi Rob,
This is really easy to do, either using RuleBuilder or TrafficScript. RuleBuilder is a simple 'if-condition-then-action' GUI front-end to TrafficScript.
Before you write your rule:
Then you need to create a rule using RuleBuilder, or write a rule using TrafficScript, to intercept the /scotland traffic and divert it to the scotland pool:
RuleBuilder
IF HTTP Path is '/scotland'
- AND -
IF HTTP Host Header is 'www.suckeggs.com'
- THEN -
Use Pool 'scotland'
TrafficScript
if( http.getHostHeader() == "www.suckeggs.com" ) {
if( http.getPath() == "/scotland" ) {
pool.use( "scotland" );
}
}
Hope that this helps
Owen
Hi Rob,
This is really easy to do, either using RuleBuilder or TrafficScript. RuleBuilder is a simple 'if-condition-then-action' GUI front-end to TrafficScript.
Before you write your rule:
Then you need to create a rule using RuleBuilder, or write a rule using TrafficScript, to intercept the /scotland traffic and divert it to the scotland pool:
RuleBuilder
IF HTTP Path is '/scotland'
- AND -
IF HTTP Host Header is 'www.suckeggs.com'
- THEN -
Use Pool 'scotland'
TrafficScript
if( http.getHostHeader() == "www.suckeggs.com" ) {
if( http.getPath() == "/scotland" ) {
pool.use( "scotland" );
}
}
Hope that this helps
Owen
Hi Owen,
Thanks for this helpful response. Unfortunately i have only just around to implementing this as the site was note ready until late this afternoon.
I have created the required groups and set up the rule using an edited version of your trafficscript (with the actual URL and HTTP Path) and whilst this no longer returns a 404 I do not get the full site I am expecting, but rather a cut down, low res version of the site.
EDIT: it looks like the HTTP Path "/scotland" is being passed to the second pool, and because this doesn't exist i receive a different page. Am i able to remove this from the URL without the end user being aware?
Thanks in advance all.
Rob
Where "unicorn" replaces the path portion of the request URL.
if( http.getHostHeader() == "www.suckeggs.com" ) {
if( http.getPath() == "/scotland" ) {
http.setpath( "/unicorn" );
pool.use( "scotland" );
}
}
Hi Rob,
As David Nahas showed, you may use http.setPath() to change the URL in the request. Stingray will then send the modified request to the selected server; the remote client does not see the changed request.
The other common method is to use http.redirect(); this sends a 302 Redirect response back to the client telling it to 'try this URL'. The redirect is visible to the end user.
One possible gotcha when using http.setPath() is that embedded relative links or redirects from the content may not work, so images, stylesheets and the rest may not be displayed (this may be why you see a cut-down, low-res version of the site). For example, if you modify a URL from /scotland/index.html to /scotland.html, then the web client will look for resources relative to /scotland/, although the content was served from /. Use the developer tools in your web browser to see if your client is requesting resources that return an unexpected 404 Not Found.
regards
Owen