0

I want to allow to see my localhost project over the LAN using Apache LIMIT directive in .htaccess

my localhost project URL is http://192.68.0.123/myproject

below is the .htaccess part which cause problem

<Limit POST PUT DELETE>
 order deny,allow
 deny from all
 allow from 192.168.0.0/255
 Satisfy any
</Limit>

but it gives error

Server error!

The server encountered an internal error and was unable to complete your request. Either the server is overloaded or there was an error in a CGI script.

Error 500

192.168.0.123 Apache/2.4.10 (Unix) OpenSSL/1.0.1i PHP/5.5.15 mod_perl/2.0.8-dev Perl/v5.16.3

my error_log is

[Fri Dec 26 11:18:36.183915 2014] [core:alert] [pid 4752] [client 192.168.0.123:38795] /opt/lampp/htdocs/myproject/.htaccess: The specified network mask is invalid.

my work around

  • If I set allow from 192.168.0.123 it works only for my IP not over LAN

  • If I set allow from 192.168.0-5.0-255 then it works fine (expected) but only the main page is coming, after login it gives Access forbidden!403

whereas it was advised to use / on this blog and many other SO answers

Does this (/ to -) changed into apache 2.4 ?

someone kindly explain the differences of these and proper valid syntax, I didn't find it on Apache documentation.


another issue

When add GET in LIMIT option

<Limit GET POST PUT DELETE>
 order deny,allow
 deny from all
 allow from 192.168.0.0-255
</Limit>

then it gives error everywhere

Access forbidden!

You don't have permission to access the requested directory. There is either no index document or the directory is read-protected.

Error 403 Access forbidden!

errro_log is

[Fri Dec 26 11:34:05.840880 2014] [access_compat:error] [pid 4752] [client 192.168.0.123:39012] AH01797: client denied by server configuration: /opt/lampp/htdocs/myproject/

1

I got the solution from this article

change the line

allow from 192.168.0.0-255 to

allow from 192.168.0.2/255.255.0.0

will lock Apache down to my internal LAN i.e. address range 192.168.0.2 to 192.168.0.255 only with subnet mask of 255.255.0.0

and it works with GET also, here is my final .htaccess

<Limit GET POST PUT DELETE>
 Order deny,allow
 Deny from all
 Allow from 127.0.0.1 ::1
 Allow from 192.168.0.2/255.255.0.0
</Limit>
0

The satisfy directive is intended to combine multiple requirements i.e. both from your subnet and a valid-user .

Leave that option out and you should have a more valid configuration.

Also it is better to use your apache configuration file rather than .htaccess files.

  • already checked with removal of satisfy but error remains. And do not have access to Apache log on server that's why I used it on .htaccess – diEcho Dec 26 '14 at 8:20

Your Answer

By clicking "Post Your Answer", you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.