Forum Discussion
FSC-IT_27241
Nimbostratus
Apr 21, 2008dazed and confused irule newbie http to https
I have a site that I am using the profile to rewrite all to map http to https. The trouble is any url redirects the site has to other sites it is also putting those to https which may or may not be supported by the native site.
Is there a way to only rewrite things that contain the mydomain.com?
- hoolio
Cirrostratus
Here is an example:when HTTP_REQUEST { Check if requested domain is mydomain.com if {[string tolower [HTTP::host]] eq mydomain.com}{ Redirect client to https HTTP::redirect https://mydomain.com[HTTP::uri] } }
- Colin_Walker_12Historic F5 AccountYou can also use a similar rule to trigger re-writes from the server to the client:
when HTTP_RESPONSE { Check if requested domain is mydomain.com if {[string tolower [HTTP::host]] eq mydomain.com}{ Redirect client to https STREAM::expression "@http@https@" STREAM::enable } }
- FSC-IT_27241
Nimbostratus
Thanks for the quick responses. Let me explain this a different way. The application we have behind the F5 will occasionally redirect to an external site. If I have the HTTP profile rewrite set to all the application will work fine on the mydomain.com. But any redirects it will put https://externaldomain.com. - hoolio
Cirrostratus
Is the insecure content warning happening because the application is sending a redirect to an http URL hosted on the VIP? Or does the page content contains absolute references to http content (http://example.com/file.jpg for example)? If it's the former, you can rewrite the redirect if it contains your domain using a rule like this:when HTTP_REQUEST { Save the requested host header value for reference in the response set host [HTTP::host] } when HTTP_RESPONSE { Check if this is a redirect (30x response status) if {[HTTP::is_redirect]}{ Replace the http://host with https://host in the Location header HTTP::header replace Location [string map -nocase "http://$host" "https://$host" [HTTP::header value Location]] } }
- FSC-IT_27241
Nimbostratus
Just FYI: This is what I went with, sorry for not sharing this sooner. Thanks for all your help.
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