Forum Discussion
rewrite the location in 302 response
- Jul 16, 2020
Hello Muhannad.
Tried this code and it works like a charm.
when HTTP_REQUEST { set fqdn_name [HTTP::host] } when HTTP_RESPONSE { set location [HTTP::header Location] set port [URI::port $location] set n_path [URI::path $location] set n_basename [URI::basename $location] set n_query [URI::query $location] if { [HTTP::is_redirect] }{ if { $port eq 80 }{ HTTP::header replace Location "https://$fqdn_name$n_path$n_basename?$n_query" } } }
Without iRule, this is the server response.
< HTTP/1.0 302 Found < Location: http://example.local:80/xx/ApplicationsLogin?applicationId=MTA=&applicationInstanceId=MQ== < Server: BigIP < Connection: Keep-Alive < Content-Length: 0
And this is the response with the iRule.
< HTTP/1.0 302 Found < Location: https://example.local/xx/ApplicationsLogin?applicationId=MTA=&applicationInstanceId=MQ== < Server: BigIP < Connection: Keep-Alive < Content-Length: 0
Regards,
Dario.
Hi Dario,
Thanks for the response, it gave me an error for the quot when i create the IRULE, i have tried without it but this didnt work :(, it stuck :
it stuck in the initial requested URL http://xxx.local/xx
is there any simple IRULE can strip to port 80 from the 302 header location.
Regards,
Muhannad
- Jul 16, 2020
Hello Muhannad.
Tried this code and it works like a charm.
when HTTP_REQUEST { set fqdn_name [HTTP::host] } when HTTP_RESPONSE { set location [HTTP::header Location] set port [URI::port $location] set n_path [URI::path $location] set n_basename [URI::basename $location] set n_query [URI::query $location] if { [HTTP::is_redirect] }{ if { $port eq 80 }{ HTTP::header replace Location "https://$fqdn_name$n_path$n_basename?$n_query" } } }
Without iRule, this is the server response.
< HTTP/1.0 302 Found < Location: http://example.local:80/xx/ApplicationsLogin?applicationId=MTA=&applicationInstanceId=MQ== < Server: BigIP < Connection: Keep-Alive < Content-Length: 0
And this is the response with the iRule.
< HTTP/1.0 302 Found < Location: https://example.local/xx/ApplicationsLogin?applicationId=MTA=&applicationInstanceId=MQ== < Server: BigIP < Connection: Keep-Alive < Content-Length: 0
Regards,
Dario.
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