Feature #926

Rewrite + Proxy

Added by Anonymous 732 days ago. Updated 55 days ago.

Status:Invalid Start:
Priority:Normal Due date:
Assigned to:- % Done:

0%

Category:mod_rewrite
Target version:-
Pending:

No

Resolution:

invalid

Patch available:


Description

It would be very nice if mod_proxy_core and mod_rewrite could be used together, i.e. to rewrite the request on the back-end server.

proxy's lighttpd.conf:


$HTTP["url"] =~ "^/motoko/" {
  url.rewrite-once = ( "^/motoko(/.*)?" => "/caio/$1" )
  proxy-core.backends = ( "myip" )
}

Request:


elinks -dump http://mydomain/motoko/3

Log of proxed web server:


proxyip mydomain - [29/Nov/2006:13:24:03 +0100] "GET /motoko/3 HTTP/1.0" 404 345 "-" "ELinks/0.11.1 (textmode; FreeBSD 6.1-STABLE i386; -)" 

What I would like is a request to `/caio/3`.

History

12/04/2006 08:05 AM - darix

  • Status changed from New to Fixed
  • Resolution set to invalid

thats expected. the original request path is logged. you should use redirect if you want to see the "rewritten" path.

12/04/2006 08:06 AM - darix

  • Status changed from Fixed to Need Feedback
  • Resolution deleted (invalid)

Replying to darix:

thats expected. the original request path is logged. you should use redirect if you want to see the "rewritten" path.

hrm i shouldnt close bugs while waking up. :| of course on the backend you should see the changed request.

sorry

12/04/2006 08:18 AM - Anonymous

BTW: using mod_proxy on latest 1.4 release is just the same as using mod_proxy_core as stated in the example (the back-end does not receive a rewritten request).

-- lapo

12/04/2006 08:32 AM - darix

can you make sure mod_proxy is loaded after mod_rewrite/redirect?

12/04/2006 09:15 AM - Anonymous

I wouldn't know how to alter the load order, except that lighttpd.conf includes the modules in this order:


server.modules = (
    "mod_rewrite",
    "mod_access",
    "mod_proxy_core",
    "mod_accesslog" 
)

-- lapo

12/04/2006 10:03 PM - jakabosky

Try this:


$HTTP["url"] =~ "^/motoko/" {
    proxy-core.balancer = "round-robin" 
    proxy-core.protocol = "http" 
    proxy-core.backends = ( "myip" )
    proxy-core.rewrite-request = (
       "_uri" => ( "^/motoko(/.*)?" => "/caio/$1" )
    )
}

If you still have problem enable this:


debug.log-request-handling = "enable" 

Also I think url.rewrite work on the request uri before the $HTTPurl conditional matching.

enable log-request-handling with your config to see what it is doing.

08/31/2008 11:05 PM - stbuehler

  • Status changed from Need Feedback to Fixed
  • Resolution set to invalid

Expected: mod_rewrite restarts a request and resets the conditional results.

10/10/2008 06:53 PM - stbuehler

  • Status changed from Fixed to Invalid

Also available in: Atom PDF