Forum Discussion

Mersin_108215's avatar
Mersin_108215
Icon for Nimbostratus rankNimbostratus
Jan 30, 2014

HTTP Respond and Redirect Together

Hi -

 

I need to be able to send an HTTP 404 along with a redirect. Can this be done? Why I want to do this... My OOS page is hosted externally. Currently I have an iRule that will send a 404 with content that is src="http://myoospage.othersite.com" This doesn't work for ssl connections, though, because it's attempting to use insecure content.

 

Any suggestions? I'm thinking if I can respond with a 404 and redirect that would work. The 404 response is a requirement.

 

Thanks!

 

  • Maybe something like this...

    when HTTP_RESPONSE {
    if { ([HTTP::status] equals "404") } {
        HTTP::respond 404 content " "
        }
    }
    
  • Maybe something like this...

    when HTTP_RESPONSE {
    if { ([HTTP::status] equals "404") } {
        HTTP::respond 404 content " "
        }
    }
    
  • Sorry, it didn't like the html tags. Anyway, you could send the 404 back to the client that includes an html redirect such as meta http-equiv=refresh content=0;url=[destination_url]

     

    • Mersin_108215's avatar
      Mersin_108215
      Icon for Nimbostratus rankNimbostratus
      Hey Tim, So this worked...kind-of :) It only works when hitting the site using Firefox. Chrome just spits out what I have in quotes IE loads the page partially. I'm a bit of a novice here... any ideas on what else I may need? Here's my iRule as it looks now: when HTTP_REQUEST { if { ([active_members [LB::server pool]] < 1 ) } { HTTP::header insert Edge-Control bypass-cache HTTP::respond 404 content " " } }
    • Mersin_108215's avatar
      Mersin_108215
      Icon for Nimbostratus rankNimbostratus
      oops, tags got me too... In quotes I have the following with the brackets replaced with http://mystatus.othersite.com meta http-equiv=refresh content=0;url=[destination_url]
    • Tim_K_92675's avatar
      Tim_K_92675
      Icon for Cirrostratus rankCirrostratus
      You'll need to add all the opening and closing html tags, such as... html head meta http-equiv=refresh content=0;url=[destination_url] head html
  • Which when added together becomes;-

        when HTTP_REQUEST {
            set 404_page " " 
    
        if {![active_members [LB::server pool]]} {
            HTTP::respond 404 content $404_page Edge-Control "bypass-cache" Cache-Control "nocache"
            return
        }
    }
    

    OR

        when HTTP_RESPONSE {
            set 404_page " " 
    
        if { [HTTP::status] == 404} {
            HTTP::respond 404 content $404_page Edge-Control "bypass-cache" Cache-Control "nocache"
            return
        }
    }
    
  • Thanks Tim K! It works.

     

    Final iRule is like this: when HTTP_REQUEST { if { ([active_members [LB::server pool]] < 1 ) } { HTTP::header insert Edge-Control bypass-cache HTTP::respond 404 content " " } }