You are viewing a plain text version of this content. The canonical link for it is here.
Posted to bugs@httpd.apache.org by bu...@apache.org on 2007/09/06 13:25:24 UTC

DO NOT REPLY [Bug 43319] New: - when combined with mod_proxy, mod_rewrite NE flag does not work correctly

DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43319>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43319

           Summary: when combined with mod_proxy, mod_rewrite NE flag does
                    not work correctly
           Product: Apache httpd-2
           Version: 2.3-HEAD
          Platform: Other
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: mod_rewrite
        AssignedTo: bugs@httpd.apache.org
        ReportedBy: rahul@sun.com


I was trying to send %3d to backend server as a reverse proxy.
--[Conf
With rewrite rule
RewriteEngine on
RewriteLogLevel 3
RewriteRule ^(.*)test.txt$  http://agneyam.india.sun.com:2000/val\%3dtest.txt 
[NE,P]

]
>[
GET /http/me/test.txt HTTP/1.0

]

gets sent to back end as

>[
GET /val%253dtest.txt HTTP/1.1
Host: agneyam.india.sun.com:2000
Max-Forwards: 10
X-Forwarded-For: 129.158.224.203
X-Forwarded-Server: agneyam
Connection: Keep-Alive

]

ie, the % gets escaped again.
If I remove the [P] from the flags, the url generated is correct.
With out mod_proxy (N) in it,

RewriteRule ^(.*)test.txt$  http://agneyam.india.sun.com:2000/val\%3dtest.txt 
[NE]
>[
GET /http/me/test.txt HTTP/1.0
]
<[
HTTP/1.1 302 Found
Date: Thu, 06 Sep 2007 08:24:42 GMT
Server: Apache/2.3.0-dev (Unix)
Location: http://agneyam.india.sun.com:2000/val%3dtest.txt
Content-Length: 232
Location: http://agneyam.india.sun.com:2000/val%3dtest.txt
Content-Length: 232
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://agneyam.india.sun.com:2000/
val%3dtest.txt">here</a>.</p>
</body></html>
]
(notice that the %3d is not munged.)

Just for checking, I removed the NE flag too, which gave the expected result 
(which, with out the NE flag is to escape %)
>[
GET /http/me/test.txt HTTP/1.0
]
<[
HTTP/1.1 302 Found
Date: Thu, 06 Sep 2007 08:26:02 GMT
Server: Apache/2.3.0-dev (Unix)
Location: http://agneyam.india.sun.com:2000/val%253dtest.txt
Content-Length: 234
Location: http://agneyam.india.sun.com:2000/val%253dtest.txt
Content-Length: 234
Connection: close
Content-Type: text/html; charset=iso-8859-1

<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN">
<html><head>
<title>302 Found</title>
</head><body>
<h1>Found</h1>
<p>The document has moved <a href="http://agneyam.india.sun.com:2000/
val%253dtest.txt">here</a>.</p>
</body></html>
]



====================================================
Just to verify the behavior, I did further tests.
====================================================

If I remove the '\' from % in rewrite rule, (Just to see what happens.)
RewriteRule ^(.*)test.txt$  http://agneyam.india.sun.com:2000/val%3dtest.txt 
[NE,P]

>[
GET /http/me/test.txt HTTP/1.0
]

gets sent to back end as

>[
GET /valdtest.txt HTTP/1.1
Host: agneyam.india.sun.com:2000
Max-Forwards: 10
X-Forwarded-For: 129.158.224.203
X-Forwarded-Server: agneyam
Connection: Keep-Alive

]

Using Rewriterule with out NE flag,
RewriteRule ^(.*)test.txt$  http://agneyam.india.sun.com:2000/val\%3dtest.txt 
[P]

>[
GET /http/me/test.txt HTTP/1.0
]

gets sent to back end as

>[
GET /val%253dtest.txt HTTP/1.1
Host: agneyam.india.sun.com:2000
Max-Forwards: 10
X-Forwarded-For: 129.158.224.203
X-Forwarded-Server: agneyam
Connection: Keep-Alive

]
(ie: there is no change from using NE and not using it.)

Using mod_proxy directly using ProxyPass and not Rewrite does it the other way
(changes Hex to chars)
with ProxyPass
ProxyRequests On
ProxyVia On
ProxyPass /http http://agneyam.india.sun.com:2000
>[
GET /http/me/val%3dtest.txt HTTP/1.0
]

gets sent to back end as:
>[
GET /me/val=test.txt HTTP/1.1
Host: agneyam.india.sun.com:2000
Max-Forwards: 10
Via: 1.0 agneyam
X-Forwarded-For: 129.158.224.203
X-Forwarded-Server: agneyam
Connection: Keep-Alive

]

=====================
Summary
=====================
The NE flag does not have an effect when mod_proxy (P) is involved.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 43319] - when combined with mod_proxy, mod_rewrite NE flag does not work correctly

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43319>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43319





------- Additional Comments From rahul@sun.com  2007-09-18 04:50 -------
Created an attachment (id=20843)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=20843&action=view)
A patch to let mod_rewrite flags P and NE co-exist.

The problem with mod_proxy (P) flag is that in 
mod_rewrite:hook_uri2file(request_rec *r)
the rulestatus != ACTION_NOESCAPE is checked only in the case when it is not a
proxy. while there is nothing done when it is a proxy.

On the other hand, the mod_proxy escapes any and every URLs that it gets. 
so the URL that we passed in with NE gets munged by mod_proxy.

The fix is to check for ACTION_NOESCAPE in the if proxy section of 
mod_rewrite:hook_uri2file(request_rec *r), and set the r->notes
apr_table_setn(r->notes, "mod_proxy:flags","NE");

and in mod_proxy_http:proxy_http_canon which is responsible for escaping HTTP
URLs, we check for the above flag's existence and if it is there, we let the
URL path in with out escaping.

The reason notes is named mod_proxy:flags rather than mod_rewrite:flags is
that the same flags may be made use of by some other module that needs proxy
functionality with out the escaping.


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 43319] - when combined with mod_proxy, mod_rewrite NE flag does not work correctly

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43319>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43319


rahul@sun.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
  Attachment #20843|0                           |1
        is obsolete|                            |




------- Additional Comments From rahul@sun.com  2007-09-18 05:00 -------
Created an attachment (id=20844)
 --> (http://issues.apache.org/bugzilla/attachment.cgi?id=20844&action=view)
fix a typo in previous patch.


-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 43319] - when combined with mod_proxy, mod_rewrite NE flag does not work correctly

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43319>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43319


serai@lans-tv.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|FixedInTrunk                |




-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 43319] - when combined with mod_proxy, mod_rewrite NE flag does not work correctly

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43319>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43319


nick@webthing.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |FIXED




------- Additional Comments From nick@webthing.com  2008-01-12 05:54 -------
Fixed in r611414.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org


DO NOT REPLY [Bug 43319] - when combined with mod_proxy, mod_rewrite NE flag does not work correctly

Posted by bu...@apache.org.
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG�
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=43319>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND�
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=43319


nick@webthing.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |FixedInTrunk




------- Additional Comments From nick@webthing.com  2008-01-11 02:55 -------
Fixed in trunk: r611134.  This is basically your patch, but tied in with my
previous fix to the same problem in mod_proxy without mod_rewrite.

-- 
Configure bugmail: http://issues.apache.org/bugzilla/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug, or are watching the assignee.

---------------------------------------------------------------------
To unsubscribe, e-mail: bugs-unsubscribe@httpd.apache.org
For additional commands, e-mail: bugs-help@httpd.apache.org