1 |
On 11/30/2020 05:34 AM, Michael wrote: |
2 |
[snip] |
3 |
> |
4 |
> I've tested different RequireAll directives in a .htaccess file and with |
5 |
> otherwise default apache settings I can confirm: |
6 |
> |
7 |
> This is correct: |
8 |
> ========================= |
9 |
> <RequireAll> |
10 |
> Require ip 10.0.0.100 |
11 |
> </RequireAll> |
12 |
> ========================= |
13 |
> will only allow visitors from 10.0.0.100 to access the directory content. |
14 |
> |
15 |
> This is also correct: |
16 |
> ========================= |
17 |
> <RequireAll> |
18 |
> Require all granted |
19 |
> Require ip 10.0.0.100 |
20 |
> </RequireAll> |
21 |
> ========================= |
22 |
> will only allow visitors from 10.0.0.100 to access the directory content. |
23 |
> |
24 |
> Finally, this won't work: |
25 |
> ========================= |
26 |
> <RequireAll> |
27 |
> Require all denied |
28 |
> Require ip 10.0.0.100 |
29 |
> </RequireAll> |
30 |
> ========================= |
31 |
> because it returns 403 for all clients irrespective of IP address, since both |
32 |
> subdirectives must be correct for the RequireAll to be true. |
33 |
> |
34 |
> I notice you have 'Options MultiViews' in your modules.d/ |
35 |
> 00_default_settings.conf, which will parse paths to find and serve any file |
36 |
> requested by the client even if the URL is not complete. It might be this |
37 |
> conflicts with your .htaccess within admin/ subdirectory, but I'm not sure. |
38 |
> Something in apache logs may shed light in this. |
39 |
> |
40 |
> |
41 |
>> AuthName "restricted stuff" |
42 |
>> AuthType Basic |
43 |
>> AuthUserFile "/etc/apache2/users" |
44 |
>> require user webmaster |
45 |
>> |
46 |
>> I've tried adding |
47 |
>> RewriteEngine on |
48 |
>> |
49 |
>> With it, I can not login at all (access denied) regardless of IP. |
50 |
> |
51 |
> With apache 2.4 a new <If> directive was added to perform conditional checks |
52 |
> and replace/augment many of the mod_rewrite functionalities. I don't know how |
53 |
> you have structured your RewriteCond and RewriteRule, but obviously they don't |
54 |
> work as intended if they totally block access. |
55 |
> |
56 |
> You could check conflicting rules between your apache config and any .htaccess |
57 |
> directives, or any loose and contradictory .htaccess files in higher |
58 |
> subdirectories. |
59 |
|
60 |
Partial success. It seems to me .htaccess <RequireAll> needs: <Files *> |
61 |
to work. |
62 |
The blow works on IP: |
63 |
|
64 |
<Files *> |
65 |
<RequireAll> |
66 |
Require ip 10.0.0.109 |
67 |
</RequireAll> |
68 |
</Files> |
69 |
|
70 |
But this below doesn't work. |
71 |
|
72 |
AuthName "restricted stuff" |
73 |
AuthType Basic |
74 |
AuthUserFile "/etc/apache2/users" |
75 |
require user webmaster |
76 |
|
77 |
It doesn't read "AuthType Basic" it does not ask me for password. |
78 |
I wish Apache 2.2 was still in portage. |