RE: [users@httpd] temporary enable/disable access

2024-08-02 Thread Marc
> 
> 
>   I have currently such virtual host config:
> 
> 
> 1 
> 2   AllowOverride All
> 3   Require all granted
> 4 
> 
>45 
>46   Order deny,allow
>47   Deny from all
>48   #Allow from all
>49   Allow from 1.1.1.1
>50   #Allow from 2.2.2.2
>51   # allow cron
> 
>   The idea is that I can quickly limit access to the website by
> uncommenting just a single line in the config. However when I change it
> to
> 
>47   #Deny from all
>48   Allow from all
> 
>   Such files in dirs are not protecting files any more
> 
>   [@]# cat /aaa/////.htaccess
>   Order deny,allow
>   Deny from all
> 
>   Anyone know what I need to add to the location /  section?
> 
> 
> 
> 
> 
> 
> 
> Why are you still using 2.2 authz directives here, out of curiosity?

Maybe more experienced users with this that can comment.


-
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org


Re: [users@httpd] temporary enable/disable access

2024-08-02 Thread Eric Covener
> >46   Order deny,allow

This allows access by default.
"Order allow,deny" denies access by default.

> >   The idea is that I can quickly limit access to the website by
> > uncommenting just a single line in the config. However when I change it
> > to
> >
> >47   #Deny from all
> >48   Allow from all

This doesn't work. Port to Require here first as Frank said.

-
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



Re: [users@httpd] temporary enable/disable access

2024-08-02 Thread Frank Gingras
On Fri, Aug 2, 2024 at 6:55 AM Eric Covener  wrote:

> > >46   Order deny,allow
>
> This allows access by default.
> "Order allow,deny" denies access by default.
>
> > >   The idea is that I can quickly limit access to the website by
> > > uncommenting just a single line in the config. However when I change it
> > > to
> > >
> > >47   #Deny from all
> > >48   Allow from all
>
> This doesn't work. Port to Require here first as Frank said.
>
> -
> To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
> For additional commands, e-mail: users-h...@httpd.apache.org
>
>
As a side note, try to avoid snarky remarks about the helper's experience
in the future, thanks.


[users@httpd] RewriteRule and redirect loop with htaccess

2024-08-02 Thread Dave Wreski

Hi,

I have a rewrite that's creating a loop because the origin is contained 
in the final destination. I know it then is processed again by the 
.htaccess in the document root, but I don't understand why or how to 
stop it. What's the solution here?


RewriteRule 
^/features/linux-malware-the-truth-about-this-growing-threat$ 
https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated 
[L,R=301,END]


I've tried variations of the above but it always creates a loop.

$ wget -O /dev/null 
https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat 
2>&1|grep -E 'Location|HTTP'
HTTP response 302 
[https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat]
HTTP response 301 
[https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated]

HTTP response 200  [https://linuxsecurity.com//features]

Thanks,
Dave



Re: [users@httpd] RewriteRule and redirect loop with htaccess

2024-08-02 Thread Frank Gingras
On Fri, Aug 2, 2024 at 10:18 AM Dave Wreski
 wrote:

> Hi,
>
> I have a rewrite that's creating a loop because the origin is contained in
> the final destination. I know it then is processed again by the .htaccess
> in the document root, but I don't understand why or how to stop it. What's
> the solution here?
>
> RewriteRule ^/features/linux-malware-the-truth-about-this-growing-threat$
> https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated
> [L,R=301,END]
>
> I've tried variations of the above but it always creates a loop.
>
> $ wget -O /dev/null
> https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat
> 2>&1|grep -E 'Location|HTTP'
> HTTP response 302  [
> https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat
> ]
> HTTP response 301  [
> https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated
> ]
> HTTP response 200  [https://linuxsecurity.com//features]
>
> Thanks,
> Dave
>
>
>
If you don't depend on mod_rewrite for anything else, I would recommend
using RedirectMatch instead.

That rule on its own won't loop, unless you have other conflicting
directive or rewrite rules.

If you must use mod_rewrite, then enabling the rewrite log will help you
pinpoint the source of the loop.


Re: [users@httpd] RewriteRule and redirect loop with htaccess

2024-08-02 Thread Dave Wreski

Hi,


I have a rewrite that's creating a loop because the origin is
contained in the final destination. I know it then is processed
again by the .htaccess in the document root, but I don't
understand why or how to stop it. What's the solution here?

RewriteRule
^/features/linux-malware-the-truth-about-this-growing-threat$

https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated
[L,R=301,END]

I've tried variations of the above but it always creates a loop.

$ wget -O /dev/null

https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat
2>&1|grep -E 'Location|HTTP'
HTTP response 302

[https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat]
HTTP response 301

[https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated]
HTTP response 200  [https://linuxsecurity.com//features]

Thanks,
Dave



If you don't depend on mod_rewrite for anything else, I would 
recommend using RedirectMatch instead.


That rule on its own won't loop, unless you have other conflicting 
directive or rewrite rules.


If you must use mod_rewrite, then enabling the rewrite log will help 
you pinpoint the source of the loop.


Are you suggesting RedirectMatch because using RewriteRule when the 
origin is a subset of the destination is a known problem?


Here's what the rewrite log trace looks like:

rewrite '/features/linux-malware-the-truth-about-this-growing-threat' -> 
'https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated'
explicitly forcing redirect with 
https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated
escaping 
https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated 
for redirect
redirect to 
https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated 
[REDIRECT/301]
init rewrite engine with requested uri 
/features/linux-malware-the-truth-about-this-growing-threat-updated


it then appears to loop through the htaccess:

rewrite 
'features/linux-malware-the-truth-about-this-growing-threat-updated' -> 
'index.php'

add per-dir prefix: index.php -> /var/www/linuxsec/html/index.php
trying to replace prefix /var/www/linuxsec/html/ with /
internal redirect with /index.php [INTERNAL REDIRECT]
init rewrite engine with requested uri /index.php

Thanks,
Dave


Re: [users@httpd] RewriteRule and redirect loop with htaccess

2024-08-02 Thread Frank Gingras
On Fri, Aug 2, 2024 at 11:08 AM Dave Wreski
 wrote:

> Hi,
>
> I have a rewrite that's creating a loop because the origin is contained in
>> the final destination. I know it then is processed again by the .htaccess
>> in the document root, but I don't understand why or how to stop it. What's
>> the solution here?
>>
>> RewriteRule ^/features/linux-malware-the-truth-about-this-growing-threat$
>> https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated
>> [L,R=301,END]
>>
>> I've tried variations of the above but it always creates a loop.
>>
>> $ wget -O /dev/null
>> https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat
>> 2>&1|grep -E 'Location|HTTP'
>> HTTP response 302  [
>> https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat
>> ]
>> HTTP response 301  [
>> https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated
>> ]
>> HTTP response 200  [https://linuxsecurity.com//features]
>>
>> Thanks,
>> Dave
>>
>>
>>
> If you don't depend on mod_rewrite for anything else, I would recommend
> using RedirectMatch instead.
>
> That rule on its own won't loop, unless you have other conflicting
> directive or rewrite rules.
>
> If you must use mod_rewrite, then enabling the rewrite log will help you
> pinpoint the source of the loop.
>
> Are you suggesting RedirectMatch because using RewriteRule when the origin
> is a subset of the destination is a known problem?
>
> Here's what the rewrite log trace looks like:
>
> rewrite '/features/linux-malware-the-truth-about-this-growing-threat' -> '
> https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated
> '
> explicitly forcing redirect with
> https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated
> escaping
> https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated
> for redirect
> redirect to
> https://linuxsecurity.com/features/linux-malware-the-truth-about-this-growing-threat-updated
> [REDIRECT/301]
> init rewrite engine with requested uri
> /features/linux-malware-the-truth-about-this-growing-threat-updated
>
> it then appears to loop through the htaccess:
>
> rewrite
> 'features/linux-malware-the-truth-about-this-growing-threat-updated' ->
> 'index.php'
> add per-dir prefix: index.php -> /var/www/linuxsec/html/index.php
> trying to replace prefix /var/www/linuxsec/html/ with /
> internal redirect with /index.php [INTERNAL REDIRECT]
> init rewrite engine with requested uri /index.php
>
> Thanks,
> Dave
>

This shows that you have another greedy rule that rewrite everything to
index.php, and then the loop starts:

 rewrite
'features/linux-malware-the-truth-about-this-growing-threat-updated' ->
'index.php'

Remember, .htaccess files are re-parsed over and over and over and over and
over until it stops matching.

You likely should be using FallbackResource for that as well.

Lastly, why are you using .htaccess files?