Forum Discussion
iRule to Redirect or forward to an ip address
I am new to iRule (and search without much success) and just wonder if anyone would give me guidance to achieve the following iRule request.
The intend is to accept the http request via Internet and then re-direct or forward to said ip address:
http://printer.domain.com/prn?printIP=10.10.10.10
result is to redirect or forward to http://10.10.10.10
If the access is via Internet, will redirect be appropriate?
Thanks in advance.
3 Replies
- Kevin_Stewart
Employee
If the IP in the query string is a 10.x.x.x address, then a redirect is probably not your best bet for external requests. You could, however, send traffic to a specific node based on the query string. Here's a very basic example:
when HTTP_REQUEST { if { [URI::query [HTTP::uri] printIP] ne "" } { node [URI::query [HTTP::uri] printIP] 80 } }This would capture the printIP query string value and send the request, via the node command, to the IP specified (and an arbitrary port assignment. This example doesn't deal with error handling (a printIP query string that isn't an IP address), or persistence (what happens on subsequent requests from the same client if the query string doesn't exist - and needs to be sticky). Not sure if you need either, so didn't include them.
- Kev_01_144655
Nimbostratus
Thanks for quick response Kevin. Certainly persistency/sticky is a consideration, how do I address that?
- Kevin_Stewart
Employee
It depends on what the client can support. Is this request with the query string the FIRST request made by the client? Will the client make subsequent requests after this first request where the query string may not exist? Does the client support HTTP cookies?
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