Bug 35999 - Port lost after call to "internal_internal_redirect" in "modules/http/http_request.c"
Summary: Port lost after call to "internal_internal_redirect" in "modules/http/http_re...
Status: RESOLVED FIXED
Alias: None
Product: Apache httpd-2
Classification: Unclassified
Component: Core (show other bugs)
Version: 2.2.6
Hardware: PC Linux
: P2 normal (vote)
Target Milestone: ---
Assignee: Apache HTTPD Bugs Mailing List
URL:
Keywords: FixedInTrunk, PatchAvailable
Depends on:
Blocks:
 
Reported: 2005-08-03 18:47 UTC by Jonas Ringh
Modified: 2010-01-09 14:37 UTC (History)
1 user (show)



Attachments
Patch that fixes the problem (637 bytes, patch)
2005-08-03 18:57 UTC, Jonas Ringh
Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Jonas Ringh 2005-08-03 18:47:51 UTC
When using "internal_internal_redirect" the server port the request was made
though is lost. As far as I can tell this is only an issue if you are using a
port that differs from the default one.

Here is one way to reproduce the bug using the rewrite engine...

1. Setup a virtual server to use at least two ports.

--- --- ---
Listen 80
Listen 81

NameVirtualHost x.x.x.x:80
NameVirtualHost x.x.x.x:81
<VirtualHost x.x.x.x:80 x.x.x.x:81>
    DocumentRoot /home/user/bugtest_web
</VirtualHost>
--- --- ---

2. In the root directory of the server, create a test script that prints the
"SERVER_PORT" environment variable. Could for instance be a CGI-script, in which
case you also need to enable ExecCGI for the directory containing the test script.

--- --- ---
#!/bin/sh
echo Content-type: text/plain
echo
echo SERVER_PORT = $SERVER_PORT
--- --- ---

3. Within a "<directory>" directive create a rewrite rule that makes a local
redirect to the test script.

--- --- ---
<directory /home/user/bugtest_web>
    RewriteEngine on
    RewriteRule test test.cgi
</directory>
--- --- ---

4. Navigate to the test file via the rewriterule on both ports...

$ lynx -dump x.x.x.x:80/test
$ lynx -dump x.x.x.x:81/test

In both cases the output will be...
SERVER_PORT = 80

The port that comes first in the virtualhost declaration is the one that is
returned. The port that corresponds to the request is obviously what should be
returned.

After sifting though the source I found that mod_rewrite uses
"ap_internal_redirect" to do the actual redirect.

"ap_internal_redirect" calls "internal_internal_redirect" to setup the
"request_rec" for the new URI. While doing that the original port information
associated with the request is not copied to the new URI.
Comment 1 Jonas Ringh 2005-08-03 18:57:54 UTC
Created attachment 15865 [details]
Patch that fixes the problem
Comment 2 Adam Hasselbalch Hansen 2007-12-27 06:14:12 UTC
This bug is still present in 2.2.6
Comment 3 Markus Stoff 2008-08-22 13:48:16 UTC
This bug is still present in 2.2.9 on Windows (not tried on other platforms, but I assume there as well).
Comment 4 Nick Kew 2009-08-23 13:32:13 UTC
Oops, this has languished a long time.
Fixed in Trunk in r807015 - thanks for the report and patch.
Comment 5 Nick Kew 2010-01-09 14:36:52 UTC
Backported to 2.2 (at last) in r807015 - thanks!
Comment 6 Nick Kew 2010-01-09 14:37:43 UTC
Bah.  That should've read backported in r897568.