Project

General

Profile

Actions

Feature #2714

closed

Allow mod_proxy to pass on the request to the local lighttpd

Added by HenrikHolst about 8 years ago. Updated about 8 years ago.

Status:
Wontfix
Priority:
Normal
Category:
mod_proxy
Target version:
-
ASK QUESTIONS IN Forums:

Description

I have created a patch which allows mod_proxy to pass-through the request to the local/current lighttpd server if the host parameter is set to "pass-through" instead of a ip address.

This allows the local lighttpd server be part of the proxy group, otherwise if one for example tried to use "127.0.0.1" there would be an infinite loop. I have such a use case myself where we run a bunch of load balanced lighttpd servers on Amazon EC2 but where some end users apply outgoing firewall rules so they cannot use the Amazon EC2 LBS (since it keeps changing ip) and thus for these I have creted a proxy config on one of the lighttpd servers so that it can spread the load out to the other servers even though the end user is only sending requests to this very server, however I noticed that there where no way for mod_proxy to include "it self" in the pool.

The attached patch simply let's the request go on if the selected host is set to "pass-through" while maintaining use statistics so that "fair" load balancing still works.


Files

mod_proxy.c.diff (831 Bytes) mod_proxy.c.diff HenrikHolst, 2016-02-06 16:15
Actions #1

Updated by gstrauss about 8 years ago

Your solution strikes me as unclean to have more than one "handler" for a request that is moderated by mod_proxy. Sometimes it is the mod_proxy handler and sometimes it is not mod_proxy, but something else on the local server.

however I noticed that there where no way for mod_proxy to include "it self" in the pool.

Would an alternative be to configure another virtual host on a different port? e.g. 127.0.0.1:88 and you could include that in your proxy pool? The caveat with this solution is that you would have to be careful to remove the :88 port on the URI when sending back HTTP redirects or other URI construction, but you are, in all likelihood already handling that if you are behind a load balancer.

Actions #2

Updated by HenrikHolst about 8 years ago

I don't know if I read you right, but AFAIK have a request handled by more than one module is standard practice in lighttpd. I might have missed something but as far as I can see this patch should make the handling by mod_proxy for a "pass-through" host to be completely transparent, i.e any other module including the lighttpd core should see it as any other request not handled by mod_proxy just like if mod_proxy had been configured inside a conditional like:

$HTTP["remoteip"] == "xxx.16.164.14" {
        proxy.balance = "fair" 
        proxy.server = (
                "" => (
                        ( "host" => "10.91.128.68" ),
                        ( "host" => "10.81.64.161" ),
                        ( "host" => "10.102.19.53" ),
                        ( "host" => "pass-through" ),
                )
        )
}

and where the source would not match that of "xxx.16.164.14".

Using a new virtual host would of course work, but it would either require to run one more lighttpd server on the same host (wasting resources) or create a rather complex configuration. Reconstructing the URI is not really done in this case since the Amazon EC2 LBS in practice is DNS round robin plus something similar to mod_proxy.

Actions #3

Updated by gstrauss about 8 years ago

You stated earlier:

however I noticed that there where no way for mod_proxy to include "it self" in the pool.

Therefore, I suggested a way, without requiring a patch, for mod_proxy to include "itself" in the pool. Your response:

Using a new virtual host would of course work, but it would ... create a rather complex configuration.

I'm sorry you feel that way. Would you provide more details as to why you think doing this would create a "rather complex configuration"? Creating a virtual host is fairly common practice, and not something considered too complex by most, so there must be something else that I am missing that is adding to the complexity. Please help me to understand.

Actions #4

Updated by gstrauss about 8 years ago

While this patch sounds like it works for @HenrikHolst, I do not think this patch is generic and I do not think it should be applied. There is at least one valid configuration which allows for the desired functionality, and in most cases that I can think of, does not, IMO, add much complexity to the configuration.

Here is one example to clarify why I do not think the proposed patch should be applied. More advanced web server load balancers include options such as health-checking a host. The health-check can be done independently, something not straightforward if some requests are "passed through" as this patch does. This is why I described the patch as "unclean". I feel that it violates the abstraction of proxying.

Actions #5

Updated by stbuehler about 8 years ago

  • Status changed from New to Wontfix

I agree that it feels dirty; but I also can understand that one wouldn't want another round of passing traffic to yourself when you can have a shortcut.

But all in all I'd like to point out that lighttpd-1.4+mod_proxy isn't the best HTTP proxy/balancer out there - using a real HTTP proxy (say haproxy) is probably a better solution.

In lighttpd2 (our development version) we have different concepts in place which might work out better too (the balancing is separated from the actual "backend handler", which can be a local handler too).

Actions

Also available in: Atom