Forum Discussion
Prerak_Tiwari_3
Nimbostratus
Sep 29, 2017iRule to check the referer presense
I am trying to write a iRule to accommodate the following, If the Referer is “mydomain.example.com” then allow the request, if not then check if requested URI is the login page then allow, if not then show 500 error.
when HTTP_REQUEST {
switch -glob [HTTP::header "Referer"] {
"https://mydomain.example.com/*" {
HTTP::redirect [HTTP::header "Referer"]
}
"" {
if{[HTTP::uri] contains "/enter.do"}{
HTTP::redirect [HTTP::header "Referer"]
}
if{!([HTTP::uri] contains "/enter.do")}{
HTTP::respond 500 content ""
}
}
}
}
After applying this iRule I am always getting 500. Can someone help me write the correct iRule?
- Stanislas_Piro2
Cumulonimbus
Hi,
don't redirect to referer:
when HTTP_REQUEST { switch -glob [HTTP::header "Referer"] { "https://mydomain.example.com/*" { do nothing and leave irule return } default { if{[HTTP::uri] contains "/enter.do"} { HTTP::redirect [HTTP::header "Referer"] } else { HTTP::respond 500 content "" } } } }
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