Forum Discussion
pkhatri_72515
Nimbostratus
Apr 02, 2010How permit part of the url access?
How to permit part of the url accessed by only few IP addresses using data group and part of the same url accessed by all?
for example
http://example.something.com/Part_one should be accessed only by 3 ip addresses (datagroup) and
http://example.something.com/Part_one/Part_all should be accessed by everybody?
Thanks,
PK.
- The_Bhattman
Nimbostratus
Hi PK,when HTTP_REQUEST { if {!([matchclass [IP::client_address] eq $::datagroup]) and ([HTTP::uri] eq "/Part_one") } { HTTP::redirect "http://[HTTP::host]/[HTTP::uri]/Part_all } }
- pkhatri_72515
Nimbostratus
Hi Bhattman, - The_Bhattman
Nimbostratus
Hi PK,when HTTP_REQEST { set uri_path [string tolower [HTTP::uri]] if {not ([matchclass [IP::client_addr] equals $::Calyton_allowed_IPs]) and ($uri_path starts_with "/claytonkb/") } log local0. "Caught [HTTP::uri] from [IP::client_addr]" HTTP::redirect "http://static.bla.com/403.htm" return } elseif { ($uri_path starts_with "/assets") } { pool acr.blah.com_http } }
when HTTP_REQUEST { switch -glob [string tolower[HTTP::uri]] { "/claytonkb*" - "/assets*" { if {not [matchclass [IP::client_addr] equals $::Calyton_allowed_IPs] }{ log local0. "Caught [HTTP::uri] from [IP::client_addr]" HTTP::redirect "http://static.bla.com/403.htm" return } pool acr.blah.com_http } } }
- pkhatri_72515
Nimbostratus
Hi Bhattman, - pkhatri_72515
Nimbostratus
And I would appreciate if you put a comment on the code, I am new to the iRule and would greatly help. Thanks/ PK. - hoolio
Cirrostratus
HTTP::redirect "http://static.bla.com/403.htm" target="_blank" rel="nofollow">http://static.bla.com/403.htm"when HTTP_REQUEST { Check the requested path set to lowercase switch [string tolower [HTTP::path]] { "/claytonkb" { Requested path was exactly /claytonkb, so check if the client IP is not in the datagroup if {not [matchclass [IP::client_addr] equals $::Calyton_allowed_IPs] }{ log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting request from [HTTP::uri]" HTTP::redirect "http://static.bla.com/403.htm" } } } }
- pkhatri_72515
Nimbostratus
OK, So i simplified the iRule like thiswhen HTTP_REQUEST { if { ([string tolower [HTTP::uri]] starts_with "/claytonkb/") or ([string tolower [HTTP::uri]] equals "/claytonkb") } { if { not ([matchclass [IP::client_addr] equals $::CityOfClayton_allowed_IPs]) } { log local0. "Caught [HTTP::uri] from [IP::client_addr]" HTTP::redirect "http://static.bla.com/403.htm" } } } and this works like it suppose to be. now can i add elseif or any other construct statement to get the http://acr.bla.com/claytonkb/Assets/Finance/permit.pdf to the same iRule and get everybody else be able to access it? I don't mind adding another iRule either, this is not heavy traffic anyways.
- hoolio
Cirrostratus
Hi PK,when HTTP_REQUEST { Check the requested path set to lowercase switch [string tolower [HTTP::path]] { "/claytonkb" - "/claytonkb/" { Requested path was exactly /claytonkb or /claytonkb/, so check if the client IP is not in the datagroup if {not [matchclass [IP::client_addr] equals $::Calyton_allowed_IPs] }{ log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting request from [HTTP::uri]" HTTP::redirect "http://static.bla.com/403.htm" } } } }
- pkhatri_72515
Nimbostratus
Hoolio, - hoolio
Cirrostratus
I assume you want to check the client IP for requests to /claytonkb/assets? If so, you can use this:when HTTP_REQUEST { Check the requested path set to lowercase switch [string tolower [HTTP::path]] { "/claytonkb/assets" - "/claytonkb" - "/claytonkb/" { Requested path was exactly /claytonkb or /claytonkb/, so check if the client IP is not in the datagroup if {not [matchclass [IP::client_addr] equals $::Calyton_allowed_IPs] }{ log local0. "[IP::client_addr]:[TCP::client_port]: Redirecting request from [HTTP::uri]" HTTP::redirect "http://static.bla.com/403.htm" } } } }
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