logo
Apache Lounge
Webmasters

 

About Forum Index Downloads Search Register Log in RSS X


Keep Server Online

If you find the Apache Lounge, the downloads and overall help useful, please express your satisfaction with a donation.

or

Bitcoin

A donation makes a contribution towards the costs, the time and effort that's going in this site and building.

Thank You! Steffen

Your donations will help to keep this site alive and well, and continuing building binaries. Apache Lounge is not sponsored.
Post new topic   Forum Index -> Apache View previous topic :: View next topic
Reply to topic   Topic: URL IP block
Author
Qmpeltaty



Joined: 06 Feb 2008
Posts: 182
Location: Poland

PostPosted: Thu 06 Aug '15 10:58    Post subject: URL IP block Reply with quote

I need to block the specific url for limited number of IPs.

www.domain.com/Console/Servlet?action=login

I can't use Location to block <Location /Console> as other links to Console must be public available. What is the lightest for resources and best way to do this ?
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Thu 06 Aug '15 14:24    Post subject: Reply with quote

That was very tricky question. It took a while, but I figured it out

Code:

   <LocationMatch ^/test.php>
      <If "%{QUERY_STRING} =~ /action=login/">
         Require ip 192.168.178.100
      </If>
   </LocationMatch>
Back to top
Qmpeltaty



Joined: 06 Feb 2008
Posts: 182
Location: Poland

PostPosted: Fri 07 Aug '15 9:18    Post subject: Reply with quote

Great. What you think about this ?

<LocationMatch "^/Console/Servlet.*$">
Require ip ..
</LocationMatch>


Another question - QUERY_STRING - is it the part of the URL after "?" , so according to my URL which part would be the QUERY_STRING ?

this www.domain.com/Console/Servlet?action=login or
www.domain.com/Console/Servlet?action=login
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Fri 07 Aug '15 10:23    Post subject: Reply with quote

With LocationMatch I didn't get it working.

Quote:
Another question - QUERY_STRING - is it the part of the URL after "?" , so according to my URL which part would be the QUERY_STRING ?


The QUERY_STRING is the part after the called url.
The questionmark is the separator of the url and the query string.
Each part of the query string is separated by a ampersand ( & ).
Each query string part must have a key and optional can have a value ( key=value ).
Back to top
Qmpeltaty



Joined: 06 Feb 2008
Posts: 182
Location: Poland

PostPosted: Fri 07 Aug '15 13:22    Post subject: Reply with quote

So in my case

URL = www.domain.com/Console/
QUERY_STRING = Servlet?action=login
Back to top
James Blond
Moderator


Joined: 19 Jan 2006
Posts: 7371
Location: Germany, Next to Hamburg

PostPosted: Fri 07 Aug '15 15:41    Post subject: Reply with quote

in your case only action=login
Back to top


Reply to topic   Topic: URL IP block View previous topic :: View next topic
Post new topic   Forum Index -> Apache