Bug 56264 - Confusing error with .htaccess rewrite to proxy when mod_proxy not active.
Summary: Confusing error with .htaccess rewrite to proxy when mod_proxy not active.
Status: NEW
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: mod_rewrite (show other bugs)
Version: 2.4.7
Hardware: All All
: P2 trivial (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
Keywords: FixedInTrunk, PatchAvailable
Depends on:
Reported: 2014-03-14 18:08 UTC by Michael Streeter
Modified: 2019-01-06 13:06 UTC (History)
0 users

Patch File (866 bytes, patch)
2014-03-14 18:08 UTC, Michael Streeter
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Michael Streeter 2014-03-14 18:08:08 UTC
Created attachment 31387 [details]
Patch File

When a rewrite to proxy is configured in the server config, a check is made to make sure mod_proxy is active.  But the same is not done if a rewrite to proxy is configured in an .htaccess file.  This can produce a misleading error.

Steps to Reproduce:
1) Disabe mod_proxy.
2) Add a RewriteRule to an .htaccess file that uses mod_proxy (i.e.):
RewriteRule . http://www.mydom.com/index.html [P,L]
3) Go to a browser and try to load the site with the .htaccess file.

Actual Results: The error_log will show an error like this:
[Fri Mar 14 11:53:20.226288 2014] [core:error] [pid 6449] (2)No such file or directory: [client] AH00132: file permissions deny server access: proxy:http://www.mydom.com/index.html

Expected Results:
[Fri Mar 14 12:02:05.964263 2014] [rewrite:error] [pid 6592] [client] AH00669: attempt to make remote request from mod_rewrite without proxy enabled: proxy:http://www.mydom.com/index.html

I believe this same issue would be on all hardware/operating systems, but in case it matters, this was tested on: CentOS 6.5 x86_64, Apache 2.4.7, apr-1.5.0, apr-util-1.5.3.

The attached patch file for the 2.4.7 version of mod_rewrite.c fixes it for me.  Basically it is the block of code from hook_uri2file that does the proxy check, copied to hook_fixup.
Comment 1 Christophe JAILLET 2018-08-22 22:00:16 UTC
Applied on trunk in r1838684.

I've just changed the APLOGNO to avoid a duplicate.
Thx for the patch.
Comment 2 Luca Toscano 2018-10-23 10:57:11 UTC
Christophe, is this change worth a backport proposal to 2.4.x?
Comment 3 Christophe JAILLET 2018-10-23 17:18:30 UTC
Yes I think so.
Avoiding a misleading diagnostic is always a good thing.

I don't remind clearly, but I'm 99% sure that I've tested the behavior before applying the patch. Will have to retest to be sure.
But you can already propose for backport.