.htaccesswebrockmongo

How can we get IP based website access?


I have installed rockmongo, and i want only i can access it via web.i have put this rule in .htaccess

order allow,deny
allow from 118.67.228.162
deny form all

But this deny every one including myself.It was working fine earlier


Solution

  • Upfront see Access control by host

    The Allow, Deny, and Order directives, provided by mod_access_compat, are deprecated and will go away in a future version. You should avoid using them, and avoid outdated tutorials recommending their use.

    Your directives reject everyone, because of

    Order Allow,Deny
    Deny from all
    

    See Order for an explanation

    Allow,Deny
    First, all Allow directives are evaluated; at least one must match, or the request is rejected. Next, all Deny directives are evaluated. If any matches, the request is rejected. Last, any requests which do not match an Allow or a Deny directive are denied by default.

    If you want to use it anyway, see the first example in Order

    In the following example, all hosts in the example.org domain are allowed access; all other hosts are denied access.

    Order Deny,Allow
    Deny from all
    Allow from example.org
    

    For a specific IPv4 address this would be

    Allow from 1.2.3.4
    

    If the client uses IPv6, the example would look like

    Allow from 2001:db8:85a3::8a2e:370:7334
    

    To find out which address is appropriate, access the web site and look into Apache's access.log file. At the end of the file, you will find something like

    1.2.3.4 - - [01/Jun/2016:10:10:58 +0200] "GET / HTTP/1.1" 403 492 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0"

    when it is IPv4, or

    2001:db8:85a3::8a2e:370:7334 - - [01/Jun/2016:10:10:58 +0200] "GET / HTTP/1.1" 403 492 "-" "Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:45.0) Gecko/20100101 Firefox/45.0"

    when it is an IPv6 address.