Forum Discussion

Gazzu's avatar
Gazzu
Icon for Nimbostratus rankNimbostratus
Nov 10, 2017

I-rule redirection

we have a DNS record "; this record is actually a CNAME for one of our load balancers which is a1.www2.xyz.com (10.xx.yy.60) This load balancer is HTTPS forced so it goes to HTTPS all the time

 

Is there any way to tell load balancer that if user requests "; , don't force it to HTTPS and only redirect when the user asks for a1.www2.xyz.com ? right now if we go to "; , it forces HTTPS and certificate is only valid for a1.www2.xyz.com

 

I Believe irule will help to fix this.Please suggest the irule for same.

 

2 Replies

  • You can redirect from http://www.xyz.com to https://a1.www2.xyz.com with a Policy or iRule with easy on the F5 LTM.

    iRule would be as follows, just update the FQDNs and apply to your HTTP Virtual Server:

    when HTTP_REQUEST {
        if {[string tolower [HTTP::host]] eq "www.xyz.com"} {
            HTTP::redirect "https://a1.www2.xyz.com[HTTP::uri]"
        }
    } 
    

    Alternatively if you want to only redirect if the client sends a request for a1.www2.xyz.com then the following should work:

    when HTTP_REQUEST {
        if {[string tolower [HTTP::host]] eq "a1.www2.xyz.com"} {
            HTTP::redirect "https://[HTTP::host][HTTP::uri]"
        }
    } 
    
  • Yes, You can solve with help of iRule. Please remove default redirection & apply customize iRule like below. Make sure both DNS record should match with A & CNAME.

    Let us know if any question?

      when HTTP_REQUEST {
        if {[string tolower [HTTP::host]] eq "www.xyz.com"}{
           HTTP::redirect "http://[HTTP::host][HTTP::uri]"
            }
            elseif {[string tolower [HTTP::host]] eq "a1.www2.xyz.com"}{
      HTTP::redirect "https://[HTTP::host][HTTP::uri]"
            }
        }