Forum Discussion
kalicut_48905
Nimbostratus
Feb 04, 2010HTTP class to redirect http to https
Hi,
Currently we have iRule that does http to https redirection for certain uri (like /app1/* & /app2/*). Can someone provide a simple example of how to do this using HTTP Class.
Thanks,
Ram
7 Replies
- The_Bhattman
Nimbostratus
Hi Ram,
Here is a some links to help out
https://support.f5.com/kb/en-us/solutions/public/9000/000/sol9047.html
https://support.f5.com/kb/en-us/solutions/public/8000/000/sol8018.html
I suppose when you associate your profile then you would choose URI path lists and set the entry type to regular expressions and enter the following "/app[1-2]/*". Then you would proceed to setup the HTTP redirect in the same profile.
I hope this helps
Bhattman - hoolio
Cirrostratus
As Bhattman suggests, you can use an HTTP class to match requests with a URI starting with /app1/ and app2/.
It's more efficient to use string matches than regexes for iRules or HTTP classes. So you could add two paths using pattern strings (/app1/* and /app2/*), set the Send To value to 'Redirect to...' and the Redirect to Location to https://[HTTP::host][HTTP::uri].
Aaron - The_Bhattman
Nimbostratus
Good point Aaron.
Bhattman - CraigM_17826
Altocumulus
Hi,
I'm in the process of replacing most of my iRules based redirects to HTTP Classes and wouldn't mind some clarifications. In my exisiting rules I use a mix of "matches","starts_with", "ends_with" and "contains". Can I use wildcards in the URI Path List when the entry type is set to Pattern String or do I have to/show use the regex option?
Are there any documents that fully explain all of the options on the HTTP class forms?
Many thanks
Craig - hoolio
Cirrostratus
Hi Craig,
I think the HTTP class evaluation for Pattern Strings uses the TCL string match wildcard options (Click here). So you can use:
/uri => matches /uri
/uri* => starts_with /uri
*/uri => ends_with /uri
*/uri* => contains /uri
/uri[0-4] => match /uri0, /uri1, /uri2, /uri3, /uri4
/uri[a-d] => match /uria, /urib, /uric, /urid
/uri[aA][bB] => match /uria, /uriA, /urib, /uriB
/uri? => match /uri followed by any single character
The string patterns are case sensitive. So you could use character ranges [aA] to match both cases, or use a regex and the (?i) modifier to specify case-insensitivity.
https://support.f5.com/kb/en-us/products/big-ip_asm/manuals/product/bigipasm9_4/BIG_IP_9_4_ASM_Config_Gd-04-1.html
The traffic classifiers perform pattern matching using either literal strings or regular expressions. The literal strings can include wildcard characters, such as asterisk (*) or question mark (?). The regular expressions use the Tcl regular expression syntax. You can use a mixture of matching types within each traffic classifier.
I remember seeing a solution which covered this in good detail, but I couldn't find it on AskF5.
Aaron - CraigM_17826
Altocumulus
Hi Aaron,
a thousand thanks. You must spend all of your spare time on these forums given your prolific number of posts. I've already moved all of my URI based redirects/uri rewrites out of the iRule and into the classes and so far the testing has gone well. Another major benifit is that I now only have to define these once for our various environments which makes life a lot easier for me.
Regards,
Craig - hoolio
Cirrostratus
Hi Craig,
Well, as the number of posts increases the time per post decreases. But yeah, maybe I need a new hobby that isn't so work related :D.
Aaron
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)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
