Forum Discussion
Ip to add path to standard redirect rule
I am looking to put together an irule that will do a rewrite of url and insert ip address from pool
Pool has two members and need to add aame path to ip address being called.
path being added is /arsys/shared/login.jsp
only ip is changing depending on which one selected.
6 Replies
- Kevin_Stewart
Employee
Can you elaborate? Are you trying to add a path (/arsys/shared/login.jsp) to the request? Under specific conditions? Where do you want to insert the IP address?
- Ed_04_156540
Nimbostratus
I have vip that is using a pool that has two members can use Ip address or serevr name of pool meber.
So when you connect to remedyqa.genre.com This will use a pool and should do a rewrite to send you to one or the other server in the pool list along with pool member address it needs to appeand to request /arsys/shared/login.jsp
so redirect with look something like this
http://ip address/arsys/shared/login.jsp
where ip address could be either pool memebr
- Kevin_Stewart
Employee
So just to be clear:
http://ip address/arsys/shared/login.jsp- "http://" is the protocol
- "ip address" is the host
- "/arsys/shared/login.jsp" is the URI
If you look at this from a command line cURL instance you might see something like this:
curl -v http://remedyqa.genre.com/arsys/shared/login.jsp GET /arsys/shared/login.jsp HTTP/1.1 Host: remedyqa.genre.com User-Agent: curl... Accept: */*You can see here that the host name (or in your case the IP address of the pool) doesn't show up in the URL of the request, but simply as a Host header. When you perform load balancing, the destination address is automatically changed to the IP address of the selected pool member. If you then need the Host header to reflect this chosen IP address, then you might use an iRule like this:
when HTTP_REQUEST_RELEASE { HTTP::header replace Host [LB::server addr] }Technically speaking, in the absence of any iRule, there's nothing in the layer 7 HTTP request or response that's actually "rewritten". LTM changes the destination address as it passes through the box, and optionally the source if using SNAT, but none of the HTTP data is altered.
- Ed_04_156540
Nimbostratus
Hi the problem i have user is only entering http://remedyqa.genre.com
We need to add /arsys/shared/login.jsp to the uri and redirect to one of the members in the pool with the adjusted host uri combination,
Sorry for being so unclear in my description.
- Kevin_Stewart
Employee
Try this:
when HTTP_REQUEST { if { [HTTP::uri] equals "/" } { HTTP::redirect "http://[HTTP::host]/arsys/shared/login.jsp" } }If the user makes a request with no URI, the iRule will redirect them to the required URI.
- Ed_04_156540
Nimbostratus
Thank you that looks like it will work and makes sense to based on your explaination of the various parts
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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