Forum Discussion
ScottG_33396
Nimbostratus
Nov 30, 2006get and replace
OK all you gurus. Here's what i want to do. I want to get data from http::header "X-Forwarded-For" and replace the data in client_addr with what I get from X-Forwarded-For. I need to grab th IP found in X-Forwarded-For and put it in the client_addr so that I can pass it to my ISA servers. Any ideas?
Thanks,
Scott
5 Replies
- hoolio
Cirrostratus
When a client makes an HTTP request, you could look at the HTTP header(s) named X-Forwarded-for and set that as the source IP address for a connection to the pool using snat .
Try checking the wiki pages for the HTTP::header, snat and pool commands and repost with any questions.
Aaron - ScottG_33396
Nimbostratus
OK, I did some seraching and came up with this iRule:
when HTTP_REQUEST {
HTTP::header insert "source_addr" [HTTP::header "X-Forwarded-For"]
}
The problem is that it puts "source_addr" and the IP from the X-Forwarded-For under "HTTP: GET Request from Client" in the packet. I need for the IP from X-Forwarded-For to replace IP: Source Address = x.x.x.x under IP: Protocol in the packet.
I tried:
when HTTP_REQUEST {
IP::header insert "Source Address" [HTTP::header "X-Forwarded-For"]
}
But of course get the error:
01070151:3: Rule [forwrd] error:
line 2: [undefined procedure: IP::header] [IP::header insert "Source Address" [HTTP::header "X-Forwarded-For"]]
Can you steer me in the right direction. - Deb_Allen_18Historic F5 AccountI think what Aaron is suggesting is using the SNAT command to change the source IP to the value of the XFF header:
Interesting idea. If default routing will ensure an appropriate return path, it may work, but could instead result in broken conversations if the source NAT is in place to force return through a specific upstream device.when HTTP_REQUEST { snat [HTTP::header "X-Forwarded-For"] }
HTH
/deb - ScottG_33396
Nimbostratus
Deb, thanks for the help. When I try to use snat in that context, I get:
01070088:3: The requested object name (snat) is invalid.
Do I need to define the snat object? - ScottG_33396
Nimbostratus
Deb, forget my last. I'm bonehead. I tried to name the new iRule SNAT. Duh!
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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