Forum Discussion
Bob_10976
Nimbostratus
Jul 12, 2010iRule to use specific server based on URL/URI request
Hello all..
When the request for https://hostdomain.com/project is requested I need to go direct and only one of the nodes in the assoicated pool. I can't have any other request go to this new node being added, at least not yet. The only request this new server is going to serve will be /projects I need all other request to go to the current node that has beeing serving the request previously.
Any suggestions on how to wright this iRule?
Thanks,
Bob
12 Replies
- hoolio
Cirrostratus
Hi Bob,
It might be easiest to create two pools: one for /project and the other for all other requests. You could then use an HTTP class which filters on URIs of /project and uses the project_pool. You can create a second HTTP class with no filters that uses the default_pool.
If you're on 9.3 or lower and don't have ASM licensed, you'd need to use an iRule to do this:when HTTP_REQUEST { Check the requested path with wildcard matching switch -glob [HTTP::path] { "/project*" { /project URI pool project_pool } default { non-/project URI pool default_pool } } }
Aaron - Bob_10976
Nimbostratus
Thanks Aaron..Thats a much better way...
A couple of quick follow up questions. We are running 10.0.1 will that iRule still apply and secondly we are possible looking at setting up a new virtual server and redirecting to that server if the URI = /projects. Can I use the same iRule you've laid out there but instead of Pool use the virtual server IP address/Name?
Thanks,
Bob - hoolio
Cirrostratus
The iRule should work for any version. And yes, you should be able to change the pool command to the virtual command. Out of curiosity, why do you want to use a separate VS for the /projects requests?
Aaron - Bob_10976
Nimbostratus
Thanks Aaron...
Its actually pretty crazy issue. We have 3 legacy web servers with secure.domain.com virtual directory setup, which are all tied into a Virtual Server Pool on the LTM and the SSL Cert resides on the LTM. The /projects site will live on a new physical server, with the same secure.domain.com virtual directory hostname setup. This new server will not house any of the legacy applications/web sites, it will be mainly used for new projects/applications. We need to utilize the SSL Cert that is associated to the secure.domain.com Virtual Server. My original thought process was to add the new server to the LTM pool and redirect any request for /projects to only that new server. However, my new thought process was that I could setup an iRule to redirect request for /projects to a new Virtual Server in the LTM that will have the new Server in its Pool along with the SSL cert association.
Thanks,
Bob - Bob_10976
Nimbostratus
It appears I'm doing something wrong, below is the code I'm using and I found two problems with it. Fist if I leave in the "default" section of the code than none of my applications/websites related to this site work. This is probably because all the vitural directories that hang off my web site, exist in a format such as: https://secure.domain.com/carpool, or /Bob or /tools, etc.. Since there is no default I took that section out. However with or with out that section the redirection is not happening. No errors messages jump out at me as being issue, not sure how to troubleshoot irules... Any suggestions?when HTTP_REQUEST { Check the requested path with wildcard matching switch -glob [HTTP::path] { "/project*" { /project URI virtual vs_new_Secure_Server_https } default { non-/project URI virtual vs_Old_Secure_Server_https } } }
Thanks,
Bob - hoolio
Cirrostratus
Hi Bob,
Setting up separate VS's for this seems like unnecessary complication. I think the simplest option would be to create a new pool for the server(s) that serve the /project application. You could then use two HTTP classes or the first iRule to select between the new and /project pool based on the requested path.
Aaron - Bob_10976
Nimbostratus
Aaron...
Thanks I think I agree, it does sound easier. Question though, how do I assign two seperate Pools to one VS, or are you referring the Pools as Nodes in a pool?
Bob - hoolio
Cirrostratus
If you create two separate pools, you can create two corresponding HTTP classes. The first class would check for paths (URIs) matching /project* and have the /project pool assigned. The second HTTP class would have no filters and have the VS's default pool assigned. The project HTTP class would look like this in the bigip.conf:profile httpclass project_httpclass { defaults from httpclass pool project_http_pool redirect none paths "/project*" }
Or if you don't like the idea of using HTTP classes for this pool selection logic, you could create a new project pool named project_http_pool and use an iRule like this to select between the VS default pool and the project pool:when CLIENT_ACCEPTED { Save the name of the VS default pool set default_pool [LB::server pool] } when HTTP_REQUEST { Check the requested path with wildcard matching switch -glob [HTTP::path] { "/project*" { /project URI pool project_http_pool } default { non-/project URI pool $default_pool } } }
Aaron - Bob_10976
Nimbostratus
Thanks Aaron...I'll look into both those options, and let you know how it goes.
Bob - Bob_10976
Nimbostratus
Aaron...So close!
I used the httpclase method, using the GUI to create the classes and it appears to be redirecting to the correct Pool for /projects however I'm finding that have to type in the default.aspx page for it to load the page, and none of the .gifs that are assoicated to that page are loading, however if put the path in the URL such as /projects/images/new.gif the image shows up fine.
When I setup the httpclass for the Project i put in the URI Path as /projects/* should I have done that a differnt way?
Thanks,
Bob
Recent Discussions
Related Content
DevCentral Quicklinks
* Getting Started on DevCentral
* Community Guidelines
* Community Terms of Use / EULA
* Community Ranking Explained
* Community Resources
* Contact the DevCentral Team
* Update MFA on account.f5.com
Discover DevCentral Connects
