Forum Discussion

darrenclegg_199's avatar
darrenclegg_199
Icon for Nimbostratus rankNimbostratus
Oct 06, 2011

HTTPS repond

I have the following irule set up for our websites and it is working fine for HTTP but when the user tries the HTTPS site they just get Internet explorer cannot display the web page

 

 

when HTTP_REQUEST {

 

if { not ([string tolower [HTTP::host]] eq "")

 

}

 

{

 

drop

 

HTTP::respond 200 content\

 

"Wrong URL entered!You have been redirected to the wrong site." "Content-Type" "text/html"

 

 

How can I set up the rule to give the HTTP responce on HTTPS sites

6 Replies

  • why do u need to use drop command?

    [root@iris:Active] config  b virtual bar list
    virtual bar {
       destination 172.28.17.33:https
       ip protocol tcp
       rules myrule
       profiles {
          clientssl {
             clientside
          }
          http {}
          tcp {}
       }
    }
    [root@iris:Active] config  b rule myrule list
    rule myrule {
       when HTTP_REQUEST {
       HTTP::respond 200 content \
       "Wrong URL entered!You have been redirected to the wrong site." "Content-Type" "text/html"
    }
    }
    
    [root@iris:Active] config  curl -ik https://172.28.17.33
    HTTP/1.0 200 OK
    Content-Type: text/html
    Server: BigIP
    Connection: Keep-Alive
    Content-Length: 61
    
    Wrong URL entered!You have been redirected to the wrong site.
    
    
  • I don't know why I need the drop command. I am new to irules and have only written 2. The rule works for HTTP sites so I kept it as it is. It won't give the reponse for HTTPS sites
  • interesting... client still gets response even having drop command in http virtual but it does not in case of https virtual.

     

     

    for your issue, please remove drop command and it would work.
  • CR77235 use drop command on the request event didn't see connection to be dropped
  • hi everyone , 
    this is example for http redirect with respond 302 custom header :
    
    example 
    `text`
    when HTTP_REQUEST {
      if { [LB::server addr] eq "" }{
        eval [LB::select]
      }
      switch [LB::server addr] {
        "IP1" {
            HTTP::respond 302 Location "[https://a.x.domain.com](https://a.x.domain.com)[HTTP::uri]" \
                            Access-Control-Allow-Origin "*"
            }
        "IP2" { 
            HTTP::respond 302 Location "[https://b.x.domain.com](https://b.x.domain.com)[HTTP::uri]" \
                            Access-Control-Allow-Origin "*" 
            }
        "IP3" { 
            HTTP::respond 302 Location "[https://c.x.domain.com](https://c.x.domain.com)[HTTP::uri]" \
                            Access-Control-Allow-Origin "*"
            }
        "IP4" { 
            HTTP::respond 302 Location "[https://d.x.domain.com](https://d.x.domain.com)[HTTP::uri]" \
                            Access-Control-Allow-Origin "*"
    
        }
      }
    }