Forum Discussion
How to use pycontrol to enable X-Forwarded-For for a list of HTTP Profiles?
Hi,
I am trying to set the value of "Insert X-Forwarded-For" to "Enabled" for a list of HTTP Profiles. Can someone please help me figure out either one of the 2 methods:
1) Using "set_insert_xforwarded_for_header_mode" in Pycontrol. How should the Profile Mode list be defined? (Reference- https://devcentral.f5.com/wiki/iControl.LocalLB__ProfileHttp__get_insert_xforwarded_for_header_mode.ashx)
2) Using the REST API to make a POST call. What should be the value for- "URL", "HEADERS", and "PAYLOAD" to make this call?
For more context, we are updating configurations to add client IP information in our logs. I'm able to retrieve the current configuration of our virtual servers, HTTP Profiles and the value of Insert X-Forwarded-For flag. The next step is to update this flag to Enabled.
Please advise.
-Thank You
Shashank
- j_wood_275543Nimbostratus
If this is a one-time action (say, due to the outcome of an audit) you could change all your HTTP profiles by using a bash script. If you have a list of all the HTTP profiles that you want to change in a text file, you could use the following one-liner at the bash prompt:
for profile in $(cat http_profiles.txt); do tmsh modify ltm profile http $profile insert-xforwarded-for enabled ; done
I don't have a platform in front of me to fully test this, but it should work.
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