Forum Discussion
Kanghis_23583
Nimbostratus
Feb 10, 2009http to https redirect
This is a fairly common task: a shopping cart application requires us to secure the transaction. Without the big-ip in place, the flow redirects any request to http:/this.domain.com/this/directory to https://this.domain.com/this/directory.
I'm a complete neophyte when it comes to writing irules but have spent sevearl hours looking at examples and related threads. This much I know so far:
I've set up two Virtual Servers with the same IP; VS1 monitoring 80 contains the irule below which should redirect any requests for this.domain.com/this/directory to the VS2 monitoring 443.
My ssl rewrite is fairly straight forward:
when HTTP_REQUEST { if { [HTTP::uri] equals "/this/directory/"} { HTTP::redirect "https://this.domain.com/this/directory/" } }
VS2 (https://this.domain.com) is monitoring 443, has a client_ssl attached and is mapped to a pool with a single node also monitoring 443. On the backend webserver (apache) we have two virtual hosts; one node member is listening to port 80 and is mapped to pool1:80 and the other node is monitoring 443 and is mapped to pool2:443.
I am obviously doing something wrong because the url being returned is http://this.domain.com/this/direcotry/* and not https://this.domain.com/this/directory/*, page error notwithstanding.
Any help would be appreciated.
- James_Quinby_46Historic F5 Accountdmkang -
when HTTP_REQUEST { HTTP::redirect https://[getfield [HTTP::host] ":" 1][HTTP::uri] }
- L4L7_53191
Nimbostratus
Here is a very generic approach, ripped right from the ask.f5.com solutions (SOL3847 to be exact). This one redirects all traffic to its https counterpart:rule redirect_rule { when HTTP_REQUEST { HTTP::redirect https://[HTTP::host][HTTP::uri] } }
when HTTP_REQUEST { if { [HTTP::uri] contains "/this/directory/" } { HTTP::redirect https://[HTTP::host][HTTP::uri] } }
- Kanghis_23583
Nimbostratus
Thanks for you input. I should have added some additional information about the trigger that launches the https://credit_card_athorization_page.when HTTP_REQUEST { log local0. "redirecting to https" if { [HTTP::uri] contains "/this/directory/"} { HTTP::redirect https://"this.domain/"[getfield [HTTP::uri] ? 2]} }
- L4L7_53191
Nimbostratus
I may be missing something, but I believe that HTTP::uri will work for you: it represents everything after the hostname. From the docs, for this request:http://www.example.com:8080/main/index.jsp?user=test&login=check
/main/index.jsp?user=test&login=check
HTTP::redirect https://[HTTP::host][HTTP::uri]
- AndrewO_4840
Nimbostratus
Posted By dmkang on 02/10/2009 2:19 PM
{ HTTP::redirect https://"this.domain/"[getfield [HTTP::uri] ? 2]} }
- Kanghis_23583
Nimbostratus
The paramters being passed in the URI do not need to be encrypted for this exercise. At the moment, all I'm trying to encrypt is Credit Card informaiton. The paramters beign passed are used to identify the user. When the user clicks on the trigger button, a javascript call opens a window (window.open (http://mydomain.com/this/directory/page.asp?parameterid1+parameterid2) with the uri information passing the parameters as http://
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