Forum Discussion
CraigM_17826
May 13, 2010Altocumulus
Removing port from a redirect
Hi all,
One of our web developers has asked me if we could strip off a port number in a redirect they are doing. I thought the following would do this, but it doesn't appear to work.
when HTTP_REPSONSE {
if { [HTTP::is_redirect] } {
if { [HTTP::header Location] contains "www.acme.com:10040" } {
log "Original Location value: [HTTP::header Location]"
HTTP::header replace Location [string map -nocase {www.acme.com:10400 www.acme.com} [HTTP::header value Location]]
log "Updated Location value: [HTTP::header Location]"
return
}
}
}
And here is what is written to the log
Original Location value: www.acme.com:10040/secure/discussion-forum
Updated Location value: www.acme.com:10040/secure/discussion-forum
Note: actually the log includes http but if I enter in a URL in this new forum s/w it does odd things to it.
Any help appreciated. Craig
- hooleylistCirrostratusHi Craig,
when HTTP_RESPONSE { if { [HTTP::is_redirect] } { if { [HTTP::header Location] contains "www.acme.com:10040" } { log local0. "Original Location value: [HTTP::header Location]" HTTP::header replace Location [string map -nocase {www.acme.com:10400 www.acme.com} [HTTP::header value Location]] } } } when HTTP_RESPONSE priority 501 { if { [HTTP::is_redirect] } { Debug logging only. Remove this event once done testing log local0. "Updated Location value: [HTTP::header Location]" } }
- CraigM_17826AltocumulusHi Aaron,
- hooleylistCirrostratusHi Craig,
- CraigM_17826AltocumulusHi Aaaron,
- CraigM_17826AltocumulusHi Aaron,
- hooleylistCirrostratusNice find. CR98328 was an issue in 9.4.x and fixed in 10.0.0 per SOL8676. Which LTM version are you testing this on?
- CraigM_17826AltocumulusHi Aaron,
- hooleylistCirrostratusThat's an odd one. Glad to hear it's working now though. Let us know if you have any more questions.
- reidgNimbostratus
I have read through about dozen threads to convert https://www.server.com:8080 to https://www.sever.com.
This is one that works! Thanks for documenting this.
When a vendor hard codes Nginx to use port 8080 for https, it gets a little messy. ;)
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