Forum Discussion

Blaisure_212538's avatar
Blaisure_212538
Icon for Nimbostratus rankNimbostratus
Jan 05, 2016

ASM Referrer Support - iRule

We have ran into a problem when we enable the web scraping policy in ASM it injects a JavaScript client-side challenge that inadvertently changes the referrer header to reflect the landing page rather than the origin page. We are trying to design an iRule that would restore the referrer header prior to sending the request to the server. But could use some input on how to properly build this, below is what we think might work in this situation.

 

when HTTP_REQUEST { if {[HTTP::header exists "Referer"] set referer [HTTP::header "Referer"] } }

 

when HTTP_REQUEST_SEND { if {$referer starts_with "http" }{ clientside{ HTTP::header replace "Referer" $referer }

 

}

 

}

 

1 Reply

  • Hi Blaisure,

    you can try the iRules below...

    when HTTP_REQUEST { 
        set referer [HTTP::header "Referer"]
    }
    
    when HTTP_REQUEST_SEND { 
        if { $referer starts_with "http" } then { 
            clientside{ 
                HTTP::header replace "Referer" $referer 
            } 
        } 
    }
    

    There is no need to test the existence of the

    [HTTP::header]
    during
    HTTP_REQUEST
    before accessing it. You will either get a "" (nothing) or a certain "referer_value" back. In
    HTTP_REQUEST_SEND
    you would then still check for valid referer information before writing it back to the request.

    Good luck with your iRules solution!

    BTW: Didn't test the functionality. But at least the formating should be now correct.

    Cheers, Kai