Forum Discussion
https matching
Hi,
I have an issue where we are re-directing http > https and adding some extra lines to a URI on the port re-direct.
When we target the Virtual server directly on HTTPS the re-direct is missed, and we just see the Admin page.. so ther serverside is not capible of the re-direct without the extended URI.
I need a solution in the HTTPS virtual server to match the Hostnames and ensure that they have the extra URI string to hit the web server directly.
so https://mysite.com/something/something
thanks
19 Replies
- nitass
Employee
do you mean to rewrite uri when sending to server? if yes, you may check HTTP::uri command.
HTTP::uri
https://devcentral.f5.com/wiki/iRules.HTTP__uri.ashx Not sure if that is what I need..
The https request needs to match against the hostname and if nothing is typed after the end of that.
so a url /
the server responds with a redirect to another site.. so its a re-direct to that location that the client receives.
- nitass
Employee
Not sure if that is what I need..
it may be easier to understand if you can give some example what you are looking for.
ok..
so if you type http://mysite.com then you are redirected from http > https and a URI is added:
so the client is now https://mysite.com/something
the issue is.. if you just type https://mysite.com you are not redircted and you dont hit the /something site that produces the server re-direct that makes it work.. you just hi the default server admin page.. which is wrong.
what i need is to match if nothing is typed into the browser after mysite.com and force a redirect with the /something added on for that condition.
- Max_Q_factor
Cirrocumulus
I think you are looking for a basic modification of the _sys_https_redirect iRule from:
when HTTP_REQUEST { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] }To something like:
when HTTP_REQUEST { if { [string tolower [HTTP::uri]] equals "/" } { HTTP::redirect https://[getfield [HTTP::host] ":" 1]/something/something } else { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] } - nitass_89166
Noctilucent
the issue is.. if you just type https://mysite.com you are not redircted and you dont hit the /something site that produces the server re-direct that makes it work.. you just hi the default server admin page.. which is wrong.
are you using irule to redirect from http://mysite.com to https://mysite.com/something? if yes, have you assigned the irule (which is being used by http virtual server) to https virtual server?
- no i have not ... but i guess it could re-direct in a loop without the matching condition.. as some of the requests are correct ??
- nitass
Employee
the issue is.. if you just type https://mysite.com you are not redircted and you dont hit the /something site that produces the server re-direct that makes it work.. you just hi the default server admin page.. which is wrong.
are you using irule to redirect from http://mysite.com to https://mysite.com/something? if yes, have you assigned the irule (which is being used by http virtual server) to https virtual server?
- no i have not ... but i guess it could re-direct in a loop without the matching condition.. as some of the requests are correct ??
- nitass
Employee
but i guess it could re-direct in a loop without the matching condition.. as some of the requests are correct ??
yes, you have to check uri before redirect similar to the one Brain suggested.
this is just another example.
e.g.
[root@ve11c:Active:In Sync] config tmsh list ltm virtual bar443 ltm virtual bar443 { destination 172.28.24.10:443 ip-protocol tcp mask 255.255.255.255 pool foo profiles { clientssl { context clientside } http { } tcp { } } rules { qux } source 0.0.0.0/0 source-address-translation { type automap } vs-index 13 } [root@ve11c:Active:In Sync] config tmsh list ltm rule qux ltm rule qux { when HTTP_REQUEST { if { [HTTP::uri] equals "/" } { HTTP::redirect "https://[HTTP::host]/something" } } } [root@ve11c:Active:In Sync] config curl -Ik https://172.28.24.10 HTTP/1.0 302 Found Location: https://172.28.24.10/something Server: BigIP Connection: Keep-Alive Content-Length: 0 How does this look ? match http request if you only have the hostname so "/" would redirect to Https with the /something/something
if you already have the /something/something you drop to the default pool.
this would be applied to the Https Virtual Server
when HTTP_REQUEST { switch -glob -- [string tolower [HTTP::uri]] { "/" { HTTP::redirect https://[getfield [HTTP::host] ":" 1]/something/something return } "/something/something/*" default { pool mysite-pool } } }
yours is more elegant i think.. [HTTP::uri]
when HTTP_REQUEST { if { [HTTP::uri] equals "/" } { HTTP::redirect "https://[HTTP::host]/something" } }
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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