Forum Discussion
iRule hlep
I need to redirect from http to https , also since some users have bookmark specific port for exmaple port 8050 in their browser to be redirect to https. how do I do that.
does this works?
when HTTP_REQUEST {
if { ([HTTP::uri] eq "/")}{
HTTP::redirect ""
}
}
when HTTP_REQUEST_SEND {
clientside {
if { ( ($example_host eq "example.com") } {
HTTP::header replace Host "example.com:8050"
}
}
}
Thx
- KJ_50941
Nimbostratus
How about this one?
Thx all
- nathe
Cirrocumulus
KJwhen HTTP_REQUEST { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] }
- KJ_50941
Nimbostratus
Thx, our requiremnets is to redirect HTTP to HTTPS and secondly if some user has bookmark port:8050 they also need to redirect to https.
or
when HTTP_REQUEST {
also what does getfield do?
- nathe
Cirrocumulus
KJ, - afedden_1985
Cirrus
Not sure if this will apply but I have used this when we know what the URI starts with and we want to redirect them to a different path on the same host, this uses a 301 redirect instead of the normal 302
when HTTP_REQUEST {
- Jnon
Nimbostratus
KJ - nitass
Employee
e.g.[root@ve10:Active] config b virtual wildcard list virtual wildcard { destination 172.28.19.79:any ip protocol 6 rules myrule profiles { http {} tcp {} } } [root@ve10:Active] config b rule myrule list rule myrule { when HTTP_REQUEST { log local0. "\[HTTP::host\] = [HTTP::host]" log local0. "\[getfield [HTTP::host] : 1\] = [getfield [HTTP::host] : 1]" log local0. "\[HTTP::uri\] = [HTTP::uri]" HTTP::redirect https://[getfield [HTTP::host] : 1][HTTP::uri] } } [root@ve10:Active] config b virtual bar list virtual bar { snat automap pool foo destination 172.28.19.79:443 ip protocol 6 profiles { clientssl { clientside } tcp {} } } on client curl -I http://172.28.19.79:8050/something -H "Host: www.somedomain.com:8050" HTTP/1.0 302 Found Location: https://www.somedomain.com/something Server: BigIP Connection: Keep-Alive Content-Length: 0 on F5 [root@ve10:Active] config tail -f /var/log/ltm Sep 30 20:53:10 local/tmm info tmm[4925]: Rule myrule : [HTTP::host] = www.somedomain.com:8050 Sep 30 20:53:10 local/tmm info tmm[4925]: Rule myrule : [getfield www.somedomain.com:8050 : 1] = www.somedomain.com Sep 30 20:53:10 local/tmm info tmm[4925]: Rule myrule : [HTTP::uri] = /something
- KJ_50941
Nimbostratus
Thank you for your help. - KJ_50941
Nimbostratus
I already have VS_80 and VS_443 and applied redirect from 80 to 443, do I need to change 80 to all port or create new VIP with all port, and can this iRule work for redirect on *_VS ? - KJ_50941
Nimbostratus
I already have VS_80 and VS_443 and applied redirect from 80 to 443, do I need to change 80 to all port or create new VIP with all port, and can this iRule work for redirect on *_VS ?
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