Learn F5 Technologies, Get Answers & Share Community Solutions Join DevCentral

Filter by:
  • Solution
  • Technology
Answers

Multiple service on same FQDN

Hi,

I have a doubt. We need to do something like this: We have an domain: www.example.com, we need that if a user put this direcction in his/her browser, the F5 send it to a server x.x.x.x, but if the user put www.example.com/something the F5 should sent it to a y.y.y.y server.

Is this possible?

Thanks in advance.

0
Rate this Question

Answers to this Question

placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Hi,

I like iRules too, but I honestly think the best approach for you is the LTM Policies... For example, define the default pool on your VS (the one where requests NOT matching the "/something" go), and define an LTM Policy searching for the matching HTTP URI, and in action send to the right pool for that URI.

No line of code required :)

Sincerely

1
Comments on this Answer
Comment made 22-Jun-2016 by Arie 2039
Good point, but (especially in the past) sooner or later the requirements exceed(ed) the options the policy offered. Still worth looking at a policy for this, though.
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

Perhaps make two pools, and apply an iRule like this:

when HTTP_REQUEST { set uri [string tolower [HTTP::uri]]

if { $uri equals "/" } {

pool NOTHING_BUT_Xs

}

else {

pool NOTHING_BUT_Ys

}

}

0
Comments on this Answer
Comment made 21-Jun-2016 by Beinwin 53
Thank you very much for your response. I am new on F5, can you explain a little bit? Like: This is correct: when HTTP_REQUEST { set uri [string tolower [HTTP::*/something]] if { $uri equals "/" } { pool THE_POOL_THAT_I_CREATED } Also the iRule had to be applied to the first vip (www.example.com)? Regards,
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

@OTS02's suggestion will work, but you have to consider other resources that are likely included. For instance, where are images, scripts, style sheets etc located?

In general, you may want to have a default server and a server for exceptions (e.g. /something). If possible, have the site owner use the subfolder for supporting files (images, style sheets, scripts) where that makes sense.

It can get tricky if you're using dynamic resources that require persistence even though they are hosted in different 'folders'. For instance, some .NET applications use /websource.axd for dynamically generated resources (e.g. images). If the page under /something instructs the client to request /webresource.axd you'll have to add some intelligence to the iRule to ensure that the request isn't routed to the other pool.

Also, consider that pages (especially the home page) can be called in a variety of ways. For instance, the home page could be /, /index.html, /default.aspx, /index.php, etc.

Lastly, you'll probably want to use HTTP::path instead of HTTP::uri as the latter includes the query string parameter, which would have an effect on the string comparison you'd be doing to route the request to the proper pool.

0
Comments on this Answer
Comment made 21-Jun-2016 by Beinwin 53
Thank you for your responde Arie. We have all the resources from /something hosted in the server y.y.y.y, that would work nice, or we can get the type of errors that you tell me? Regards,
0
Comment made 21-Jun-2016 by OTS02 595
Hi Beinwin You are close. It would be something like this: when HTTP_REQUEST { set uri [string tolower [HTTP::uri]] if { $uri contains "/something" } { pool THE_POOL_THAT_I_CREATED } } BUT - everything that Arie says is correct (espescially using HTTP::path instead of HTTP::uri)
0
Comment made 22-Jun-2016 by Beinwin 53
Hi OTS02, thank you very much for your quick response. Can I make you 2 last questions? when HTTP_REQUEST { set uri [string tolower [HTTP::path]] if { $uri contains "/something/*" } { pool NOTHING_BUT_Xs } else { pool NOTHING_BUT_Ys } } First is, I can work with regex in the if like the "*" that I put. The second is, can I have an else if? Thanks in advace
0
Comment made 22-Jun-2016 by Vijay 4784
You can use regex but I would recommend not using it in iRule as it tends to be inefficient in terms of high resource utilization on the F5. See if you can use any of the string manipulation commands. Yes, you can use elseif. See - https://devcentral.f5.com/articles/irules-101-01-introduction-to-irules
0
placeholder+image
USER ACCEPTED ANSWER & F5 ACCEPTED ANSWER

@Beinwin - without knowing what kind of application you're hosting and on which platform I can't determine what kind of challenges you may run into.

However, I would start by catching all traffic to /something and routing that to the pool for it. Set the default pool for the VIP to the pool for /. That should get you mostly there. Keep in mind that by doing that the VIP will be marked down if there's a problem with the pool for /, even if the pool for /something is perfectly fine.

0