https://bz.apache.org/bugzilla/show_bug.cgi?id=63866

            Bug ID: 63866
           Summary: Rewrite rule for root URL path (/) matches and proxies
                    request, but END flag is ignored and mod_dir issues
                    sub-requests for index files
           Product: Apache httpd-2
           Version: 2.4.41
          Hardware: PC
                OS: Linux
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mod_rewrite
          Assignee: [email protected]
          Reporter: [email protected]
  Target Milestone: ---

Apache 2.4.41 on Ubuntu 16.04.5 LTS.

>From what I gather from the docs, the use of the END flag should prevent sub
requests but it does not - at least not when used in conjunction with the P
flag. 

It seems that the issue only happens when requesting existing directories (/,
/existing_dir, /dir/existing_sub_dir), it does not happen for file requests.

As a workaround, the undesired behaviour can be fixed by disabling the
DirectoryIndex.

Here is the rewrite rule:

RewriteRule (.*) http://127.0.0.1:3000/test?q=$1 [P,END]

Here is the debug (trace5) log sample:

[Fri Oct 18 20:30:16.179651 2019] [rewrite:trace3] [pid 17308:tid
140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - -
[test1.local/sid#7fbe14d530b8][rid#7fbdf80930a0/initial] [perdir
/var/www/html/test1/website/public/] strip per-dir prefix:
/var/www/html/test1/website/public/ ->
[Fri Oct 18 20:30:16.179688 2019] [rewrite:trace3] [pid 17308:tid
140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - -
[test1.local/sid#7fbe14d530b8][rid#7fbdf80930a0/initial] [perdir
/var/www/html/test1/website/public/] applying pattern '(.*)' to uri ''
[Fri Oct 18 20:30:16.179694 2019] [rewrite:trace2] [pid 17308:tid
140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - -
[test1.local/sid#7fbe14d530b8][rid#7fbdf80930a0/initial] [perdir
/var/www/html/test1/website/public/] rewrite '' ->
'http://127.0.0.1:3000/test?q='
[Fri Oct 18 20:30:16.179699 2019] [rewrite:trace3] [pid 17308:tid
140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - -
[test1.local/sid#7fbe14d530b8][rid#7fbdf80930a0/initial] split
uri=http://127.0.0.1:3000/test?q= -> uri=http://127.0.0.1:3000/test, args=q=
[Fri Oct 18 20:30:16.179703 2019] [rewrite:trace2] [pid 17308:tid
140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - -
[test1.local/sid#7fbe14d530b8][rid#7fbdf80930a0/initial] [perdir
/var/www/html/test1/website/public/] escaped URI in per-dir context for proxy,
http://127.0.0.1:3000/test -> http://127.0.0.1:3000/test
[Fri Oct 18 20:30:16.179706 2019] [rewrite:trace2] [pid 17308:tid
140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - -
[test1.local/sid#7fbe14d530b8][rid#7fbdf80930a0/initial] [perdir
/var/www/html/test1/website/public/] forcing proxy-throughput with
http://127.0.0.1:3000/test
[Fri Oct 18 20:30:16.179710 2019] [rewrite:trace1] [pid 17308:tid
140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - -
[test1.local/sid#7fbe14d530b8][rid#7fbdf80930a0/initial] [perdir
/var/www/html/test1/website/public/] go-ahead with proxy request
proxy:http://127.0.0.1:3000/test?q= [OK]
[Fri Oct 18 20:30:16.179756 2019] [rewrite:trace3] [pid 17308:tid
140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - -
[test1.local/sid#7fbe14d530b8][rid#7fbdf80710a0/subreq] [perdir
/var/www/html/test1/website/public/] strip per-dir prefix:
/var/www/html/test1/website/public/index.html -> index.html
[Fri Oct 18 20:30:16.179760 2019] [rewrite:trace3] [pid 17308:tid
140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - -
[test1.local/sid#7fbe14d530b8][rid#7fbdf80710a0/subreq] [perdir
/var/www/html/test1/website/public/] applying pattern '(.*)' to uri
'index.html'
[Fri Oct 18 20:30:16.179768 2019] [rewrite:trace2] [pid 17308:tid
140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - -
[test1.local/sid#7fbe14d530b8][rid#7fbdf80710a0/subreq] [perdir
/var/www/html/test1/website/public/] rewrite 'index.html' ->
'http://127.0.0.1:3000/test?q=index.html'
[Fri Oct 18 20:30:16.179771 2019] [rewrite:trace3] [pid 17308:tid
140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - -
[test1.local/sid#7fbe14d530b8][rid#7fbdf80710a0/subreq] split
uri=http://127.0.0.1:3000/test?q=index.html -> uri=http://127.0.0.1:3000/test,
args=q=index.html
[Fri Oct 18 20:30:16.179774 2019] [rewrite:trace2] [pid 17308:tid
140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - -
[test1.local/sid#7fbe14d530b8][rid#7fbdf80710a0/subreq] [perdir
/var/www/html/test1/website/public/] escaped URI in per-dir context for proxy,
http://127.0.0.1:3000/test -> http://127.0.0.1:3000/test
[Fri Oct 18 20:30:16.179777 2019] [rewrite:trace2] [pid 17308:tid
140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - -
[test1.local/sid#7fbe14d530b8][rid#7fbdf80710a0/subreq] [perdir
/var/www/html/test1/website/public/] forcing proxy-throughput with
http://127.0.0.1:3000/test
[Fri Oct 18 20:30:16.179787 2019] [rewrite:trace1] [pid 17308:tid
140453997967104] mod_rewrite.c(483): [client 10.20.0.40:62131] 10.20.0.40 - -
[test1.local/sid#7fbe14d530b8][rid#7fbdf80710a0/subreq] [perdir
/var/www/html/test1/website/public/] go-ahead with proxy request
proxy:http://127.0.0.1:3000/test?q=index.html [OK]

-- 
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to