Forum Discussion
redirect to 403 page error
Using the irule below.Instead of the client getting a blank page, I'd like to redirect them or dispay a 403 page error. Where in this irule would I add that. Uswhen HTTP_REQUEST {
if { ( [string tolower [HTTP::uri]] starts_with "/books" ) } { if { not ( [IP::addr [IP::client_addr] equals "55.66.77.88"] ) or not ( [IP::addr [IP::client_addr] equals "66.77.88.99"] or not ( [IP::addr [IP::client_addr] equals "77.88.99.10"] ) } { HTTP::redirect "https://[HTTP::host]/" } } }
6 Replies
- Thomas_Gobet
Nimbostratus
Could you tell us under which condition you'd like to redirect your client ?
Remember to paste code with a tabulation at the beginning of the line, it will easier to read it. - Gill_32697
Nimbostratus
If the client uri starts with /books, but is not from one of these 3 ip's then they are denied access to page. currently they get a white blank page. We would like the browser to return a 403 page error. So Here is the logic...
Vip ip/dns name is //mystore.com If client is going to //mystore.com - then allow If client is going to //mystore.com/books and src ip is one of the 3 ip's - then all.
anything else gets the 403...
So far looks to be working for //mystore.com clients, we are waiting for /books src ip's to test. Currently if client is //mystore/books and not the src IP's, they get a blank page, that's good but would like the 403 page.
when HTTP_REQUEST {
if { ( [string tolower [HTTP::uri]] starts_with "/books" ) } { if { not ( [IP::addr [IP::client_addr] equals "55.66.77.88"] ) or not ( [IP::addr [IP::client_addr] equals "66.77.88.99"] or not ( [IP::addr [IP::client_addr] equals "77.88.99.10"] ) } { HTTP::redirect "https://[HTTP::host]/" } } } - Thomas_Gobet
Nimbostratus
Could you please add a tabulation or do ctrl+k when you insert code ?
Your iRule should work, but it can be improved by using a datagroup instead of multiple single IPs.
- Gill_32697
Nimbostratus
Thanks, but Im not getting a 403 message. I just get a blank page, how do I get 403 display on the page.
- nathe
Cirrocumulus
Gilbert
You can use the HTTP::respond command.HTTP::respond wiki
So something like:
HTTP::respond 403 content {Blocked!}Hope this helps, N
- Gill_32697
Nimbostratus
I'll try it, thank you.
Help guide the future of your DevCentral Community!
What tools do you use to collaborate? (1min - anonymous)Recent Discussions
Related Content
* 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