Ticket #1206 (new defect)

Opened 1 year ago

Last modified 4 months ago

mod_proxy_core fails to rewrite proxy URL [fixed => ADD TO TRUNK!]

Reported by: quietdragon Assigned to: jan
Priority: highest Milestone: 1.5.0
Component: mod_proxy_core Version: 1.5.x-svn
Severity: major Keywords: reverse proxy patch
Cc: Blocking:
Need Feedback: 1

Description

I built http://www.lighttpd.net/download/lighttpd-1.5.0-r1857.tar.gz and I'm trying to follow the instructions at:

http://blog.lighttpd.net/articles/2006/07/18/reverse-proxying-mod_proxy_core

The lighttpd.conf I'm using is below. I've started a Mongrel session at localhost:3000, and when I browse to http://localhost/proxy, Mongrel tells me:

Processing SiteController#show_page (for 192.168.1.17 at 2007-05-30 08:58:20) [GET]
  Parameters: {"url"=>["proxy"], "action"=>"show_page", "controller"=>"site"}
Completed in 0.74100 (1 reqs/sec) | DB: 0.02960 (3%) | 404 Not Found  [http://localhost/proxy]

404 Not Found http://localhost/proxy ???

The proxy-core.rewrite-request should have stripped the /proxy/ header from the URI.

I've even tried:

"_uri" => ( "^(.*)" => "/" ),

with no effect.

server.username             = "lighttpd"
server.groupname            = "lighttpd"

server.modules           = ( "mod_rewrite",
                             "mod_alias",
                             "mod_accesslog",
                             "mod_proxy_core",
                             "mod_proxy_backend_http" )

server.errorlog          = "/var/log/lighttpd/error_log"
accesslog.filename       = "/var/log/lighttpd/access_log"

server.document-root     = "/home/www/localhost/"

$HTTP["url"] =~ "^/proxy(/|$)" {

        proxy-core.rewrite-response = (
            "_uri" => ( "^/(.*)" => "/proxy/$1" ),
        )
        proxy-core.rewrite-request = (
            "_uri" => ( "^/proxy/?(.*)" => "/$1" ),
            "Host" => ( ".*" => "localhost:3000" )
        )

        proxy-core.balancer = "round-robin"
        proxy-core.protocol = "http"
        proxy-core.backends = ( "localhost:3000" )
        proxy-core.max-pool-size = 1
}

Attachments

lighttpd.diff (390 bytes) - added by tx on 05/31/2007 03:21:28 PM.
mod_proxy_core.patch (0.6 kB) - added by rush@logic.cz on 09/25/2007 06:10:54 PM.

Change History

05/30/2007 04:43:30 PM changed by tx

I have similar problem too

partial lighttpd.conf:

$HTTP["url"] =~ "^/$" {
   proxy-core.balancer       = "round-robin"
   proxy-core.protocol       = "http"
   proxy-core.backends          = ( "google.com" )
}

error.log

response.c.165: (trace) run condition:
response.c.217: (trace) -- splitting Request-URI
response.c.218: (trace) Request-URI  : /
response.c.219: (trace) URI-scheme   : http
response.c.220: (trace) URI-authority: xxx.xx
response.c.221: (trace) URI-path     : /
response.c.222: (trace) URI-query    : (null)
response.c.276: (trace) -- sanitizing URI
response.c.277: (trace) URI-path     : /
configfile-glue.c.500: (trace) === start of 1 condition block ===
configfile-glue.c.450: (trace) 'HTTP["url"]': '/' is matched against '^/$'
configfile-glue.c.521: (trace) [1] result: true
mod_access.c.138: (trace) -- handling file in mod_access
response.c.393: (trace) -- before doc_root
response.c.394: (trace) Doc-Root     : /var/www/
response.c.395: (trace) Rel-Path     : /
response.c.396: (trace) Path         : /var/www
response.c.449: (trace) -- after doc_root
response.c.450: (trace) Doc-Root     : /var/www/
response.c.451: (trace) Rel-Path     : /
response.c.452: (trace) Path         : /var/www
mod_proxy_core.c.2180: (trace) handling it in mod_proxy_core: uri.path=/
response.c.471: (trace) -- logical -> physical
response.c.472: (trace) Doc-Root     : /var/www/
response.c.473: (trace) Rel-Path     : /
response.c.474: (trace) Path         : /var/www
plugin.c.387: (trace) -- plugins_call_...: plugin 'mod_proxy_core' returns 4
plugin.c.387: (trace) -- plugins_call_...: plugin 'mod_proxy_core' returns 4
plugin.c.387: (trace) -- plugins_call_...: plugin 'mod_proxy_core' returns 4

05/31/2007 07:59:07 AM changed by rgut@money.pl

the same regarding me...

05/31/2007 12:57:03 PM changed by anonymous

dupa

05/31/2007 03:20:56 PM changed by tx

after some investigation i found r1838 commit was breaking proxy-core.rewrite-request

test configuration

$HTTP["url"] =~ "^/proxy($|/)" {
        proxy-core.protocol = "http"
        proxy-core.balancer = "static"
        proxy-core.backends = ( "yahoo.com" )
        proxy-core.rewrite-request = (
                "_uri" => ( "/proxy/?(.*)" => "/$1" ),
                "Host" => ( ".*" => "yahoo.com"),
        )
}

atached patch fixes it

05/31/2007 03:21:28 PM changed by tx

  • attachment lighttpd.diff added.

08/07/2007 04:52:03 PM changed by robert

  • pending changed.

imho wrong way... after successfully pcre_replace we are copying p->replace_buf into sess->request_uri but... later in the same file we are overwritting sess->request_uri (using con->request.uri). so, i think copying into sess->request_uri is a mistake.

08/26/2007 06:04:06 PM changed by anonymous

  • priority changed from normal to highest.
  • pending set to 1.

08/31/2007 04:35:22 AM changed by anonymous

  • summary changed from mod_proxy_core fails to rewrite proxy URL to www.alsaha.com.

09/05/2007 04:24:12 AM changed by anonymous

  • summary changed from www.alsaha.com to mod_proxy_core fails to rewrite proxy URL.

09/25/2007 06:10:06 PM changed by rush@logic.cz

  • summary changed from mod_proxy_core fails to rewrite proxy URL to mod_proxy_core fails to rewrite proxy URL [fixed].

Hi, I think this bug should be fixed this way. See mod_proxy_core.patch

09/25/2007 06:10:54 PM changed by rush@logic.cz

  • attachment mod_proxy_core.patch added.

12/04/2007 03:59:57 AM changed by djunky

Would someone please - for gods sake - submit this patch to the trunk?

01/11/2008 05:28:04 AM changed by anonymous

don't worry yourself... lighttpd is abandonware now

01/11/2008 09:24:49 PM changed by bdferris@gmail.com

Please please please add mod_proxy_core.patch to the trunk.

01/11/2008 09:25:42 PM changed by anonymous

  • summary changed from mod_proxy_core fails to rewrite proxy URL [fixed] to mod_proxy_core fails to rewrite proxy URL [fixed => ADD TO TRUNK!].

01/25/2008 04:36:43 PM changed by stbuehler

  • keywords changed from reverse proxy to reverse proxy patch.

Another possibility would be to write the rewrite-result back into con->request.uri; but either way it should be fixed.

Hint for the future: add "patch" to the keywords.


Add/Change #1206 (mod_proxy_core fails to rewrite proxy URL [fixed => ADD TO TRUNK!])




Change Properties