Re: [users@httpd] mod_proxy_balancer - no way to name pool members by IP.

2011-04-20 Thread dfw-apache
On Wed, Apr 20, 2011 at 02:17:43PM -0400, Eric Covener wrote:
> > and I don't *think* anything looks at the Host header in the cached object,
> 
> you could add a Vary on the Host header.

I'd rather not play with the Host header after all if I can help it.

If it Vary's on Host, won't it check that the Host matches the cached object's 
Host? Which it never will coz we broke it to get the backend proxy Host header 
working.

DFW

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



Re: [users@httpd] mod_proxy_balancer - no way to name pool members by IP.

2011-04-20 Thread Eric Covener
> and I don't *think* anything looks at the Host header in the cached object,

you could add a Vary on the Host header.

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



Re: [users@httpd] mod_proxy_balancer - no way to name pool members by IP.

2011-04-20 Thread dfw-apache
On Fri, Feb 04, 2011 at 11:06:48PM +, dfw-apa...@white.u-net.com wrote:
> On Fri, Feb 04, 2011 at 05:36:01PM +, Igor Gali?? wrote:
> > 
> > > > > But ProxySet only allows you to set the same Variables as
> > > > > ProxyPass does. host is none of them.
> > > > 
> > > > Indeed. This appears to be the problem. Such an option is missing.
> > > 
> > > Right now I'm looking into 2.2's source to see how to add an option
> > > preservehost=(on|off).
> > > 
> > > Can you please test:
> > > http://people.apache.org/~igalic/patches/mod_proxy-preserve_host.diff
> > > 
> > > duh.. nodocumentationpatch!
> > > But I'm pretty sure you can guess how to use it ;)
> > 
> > http://people.apache.org/~igalic/patches/mod_proxy-preserve_host.2.diff
> > Adds: Documentation, CHANGES update, MMN bump
> > Also has a _set variable analogous to the other options.
> > 
> > Bonus: compiles.
> > Untested so far.
> 
> Thanks. I've poked and snuffled, but a co-worker has pointed out that
> there may be problems if this worker is a member of two different balance
> pools. The connection properties would be controlled by the worker, but
> what is sent down that connection should be controlled by the balancer pool.
> 
> I followed your earlier lead when you mentioned ProxyPreserveHost is now
> localisable in trunk. I dug out svn commit r824072 which looks to be exactly
> what I need. It should prevent shared workers getting mixed up by allowing
> me to set the Host at the  level.
> 
> I have a sneaking suspicion trying to set http://10.*> for a worker
> would never work anyway, as the system won't see that as the destination.
> It will see the balancer instead, so only the  config
> would apply anyway.
> 
> We'll see how far I get.

As it turns out, after a very long journey, I didn't get very far at all.

After backporting the localisable ProxyPreserveHost patch I successfully 
overwrote the Host header from inside a Proxy block, allowing me to control 
which vhost I talked to on the backend member. Unfortunately this kludged Host 
header makes its way into your cached object headers and your access log...

Now, you can fix the log by catching the Host in a Setenvif and logging that, 
and I don't *think* anything looks at the Host header in the cached object, but 
it turns out there is a more unpleasant problem :

This works as expected :
RewriteRule /foo(.*) balancer://back.foo.com/fooback/$1 [P]

And this also proxypasses, but *none* of the directives in the  take effect: 

 RewriteRule /foo(.*) balancer://back.foo.com/fooback/$1 [P]


No, I don't know why. Without the Proxy block directives to control the Host 
header sent to the backend, the backend gives us the finger, as its balancer 
member IP/hostname is not the vhost we want.

I also needed to backport a few mod_proxy_http.c thread safety patches from 2.3 
to 2.2.17 or else apachebenching was just a massacre.

I think I'm going to have to retreat. It looks like I will need a patch to 
*specify* a host header at the balancer config level.

Does anyone have any tips on how this might be done?

DFW

PS: "Ignoring parameter 'lbset=0' for worker 'http://10.1.2.3' because of 
worker sharing" (I backported a log verbosity patch too) 

Ignoring the other variables I can understand, but shouldn't lbset be unique to 
each balancer? e.g. I share the same backend workers amongst several balancers, 
but each backend IP may serve each vhost to a differing degree.


-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



Re: [users@httpd] mod_proxy_balancer - no way to name pool members by IP.

2011-04-20 Thread dfw-apache
On Fri, Feb 04, 2011 at 11:06:48PM +, dfw-apa...@white.u-net.com wrote:
> On Fri, Feb 04, 2011 at 05:36:01PM +, Igor Gali?? wrote:
> > 
> > > > > But ProxySet only allows you to set the same Variables as
> > > > > ProxyPass does. host is none of them.
> > > > 
> > > > Indeed. This appears to be the problem. Such an option is missing.
> > > 
> > > Right now I'm looking into 2.2's source to see how to add an option
> > > preservehost=(on|off).
> > > 
> > > Can you please test:
> > > http://people.apache.org/~igalic/patches/mod_proxy-preserve_host.diff
> > > 
> > > duh.. nodocumentationpatch!
> > > But I'm pretty sure you can guess how to use it ;)
> > 
> > http://people.apache.org/~igalic/patches/mod_proxy-preserve_host.2.diff
> > Adds: Documentation, CHANGES update, MMN bump
> > Also has a _set variable analogous to the other options.
> > 
> > Bonus: compiles.
> > Untested so far.
> 
> Thanks. I've poked and snuffled, but a co-worker has pointed out that
> there may be problems if this worker is a member of two different balance
> pools. The connection properties would be controlled by the worker, but
> what is sent down that connection should be controlled by the balancer pool.
> 
> I followed your earlier lead when you mentioned ProxyPreserveHost is now
> localisable in trunk. I dug out svn commit r824072 which looks to be exactly
> what I need. It should prevent shared workers getting mixed up by allowing
> me to set the Host at the  level.
> 
> I have a sneaking suspicion trying to set http://10.*> for a worker
> would never work anyway, as the system won't see that as the destination.
> It will see the balancer instead, so only the  config
> would apply anyway.
> 
> We'll see how far I get.

As it turns out, after a very long journey, I didn't get very far at all.
I needed to backport a few mod_proxy thread safety patches from 2.3 to 2.2.17 
or else apachebench was just a massacre.

After backporting the localisable ProxyPreserveHost patch I successfully 
overwrote the Host header from inside a Proxy block, allowing me to control 
which vhost I talked to on the backend member. Unfortunately this kludged Host 
header makes its way into your cached object headers and your access log...

Now, you can fix the log by catching the Host in a Setenvif and logging that, 
and I don't *think* anything looks at the Host header in the cached object, but 
it turns out there is a more unpleasant problem :

This works as expected :
RewriteRule /foo(.*) balancer://back.foo.com/fooback/$1 [P]

And this also proxypasses, but *none* of the directives in the  take effect: 

 RewriteRule /foo(.*) balancer://back.foo.com/fooback/$1 [P]


No, I don't know why. Without the Proxy block directives to control the Host 
header sent to the backend, the backend gives us the finger, as its balancer 
member IP/hostname is not the vhost we want.

I think I'm going to have to retreat. It looks like I will need a patch to 
*specify* a host header at the balancer config level.

Does anyone have any tips on how this might be done?

DFW

PS: "Ignoring parameter 'lbset=0' for worker 'http://10.1.2.3' because of 
worker sharing" (I backported a log verbosity patch too) 

Ignoring the other variables I can understand, but shouldn't lbset be unique to 
each balancer? e.g. I share the same backend workers amongst several balancers, 
but each backend IP may serve each vhost to a differing degree.


-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



Re: [users@httpd] mod_proxy_balancer - no way to name pool members by IP.

2011-02-04 Thread dfw-apache
On Fri, Feb 04, 2011 at 05:36:01PM +, Igor Gali?? wrote:
> 
> > > > But ProxySet only allows you to set the same Variables as
> > > > ProxyPass does. host is none of them.
> > > 
> > > Indeed. This appears to be the problem. Such an option is missing.
> > 
> > Right now I'm looking into 2.2's source to see how to add an option
> > preservehost=(on|off).
> > 
> > Can you please test:
> > http://people.apache.org/~igalic/patches/mod_proxy-preserve_host.diff
> > 
> > duh.. nodocumentationpatch!
> > But I'm pretty sure you can guess how to use it ;)
> 
> http://people.apache.org/~igalic/patches/mod_proxy-preserve_host.2.diff
> Adds: Documentation, CHANGES update, MMN bump
> Also has a _set variable analogous to the other options.
> 
> Bonus: compiles.
> Untested so far.

Thanks. I've poked and snuffled, but a co-worker has pointed out that
there may be problems if this worker is a member of two different balance
pools. The connection properties would be controlled by the worker, but
what is sent down that connection should be controlled by the balancer pool.

I followed your earlier lead when you mentioned ProxyPreserveHost is now
localisable in trunk. I dug out svn commit r824072 which looks to be exactly
what I need. It should prevent shared workers getting mixed up by allowing
me to set the Host at the  level.

I have a sneaking suspicion trying to set http://10.*> for a worker
would never work anyway, as the system won't see that as the destination.
It will see the balancer instead, so only the  config
would apply anyway.

We'll see how far I get.

DFW


-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



Re: [users@httpd] mod_proxy_balancer - no way to name pool members by IP.

2011-02-04 Thread Igor Galić

> > > But ProxySet only allows you to set the same Variables as
> > > ProxyPass does. host is none of them.
> > 
> > Indeed. This appears to be the problem. Such an option is missing.
> 
> Right now I'm looking into 2.2's source to see how to add an option
> preservehost=(on|off).
> 
> Can you please test:
> http://people.apache.org/~igalic/patches/mod_proxy-preserve_host.diff
> 
> duh.. nodocumentationpatch!
> But I'm pretty sure you can guess how to use it ;)

http://people.apache.org/~igalic/patches/mod_proxy-preserve_host.2.diff
Adds: Documentation, CHANGES update, MMN bump
Also has a _set variable analogous to the other options.

Bonus: compiles.
Untested so far.

i

-- 
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.ga...@brainsware.org
URL: http://brainsware.org/

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



Re: [users@httpd] mod_proxy_balancer - no way to name pool members by IP.

2011-02-04 Thread Igor Galić

- dfw-apa...@white.u-net.com wrote:

> On Thu, Feb 03, 2011 at 11:00:25PM +, Igor Gali?? wrote:
> > - dfw-apa...@white.u-net.com wrote:
> > > I've hit a vexing impasse with mod_proxy_balancer.
> > > 
> > > I have a pool of backend boxes. They vhost many domains, so
> > > need the specific Host: header in requests to them (the *same*
> > > Host: header for all of them)
> > > 
> > > I proxy requests to them potentially thousands of times a second, 
>  
> > > and their IP's are not going to be changing, so I name the
> > > BalancerMembers by IP address, as the DNS lookup overhead is 
> > > a fatal waste of CPU, especially if your DNS servers melt
> > > and your site dies unnecessarily. (No, /etc/hosts is not
> possible.
> > 
> > http://httpd.apache.org/docs/current/mod/mod_proxy.html#startup
> 
> That only mentions ProxyBlock. We do not use ProxyBlock. Also, when
> we
> lost DNS, we lost the site, so reality has the last word regardless.

duh. Sorry, must've been late yesternight, I didn't give it my full
attention.

> > > The sitename has multiple A records, and I make the backends
> choose
> > > individualiseable vhosts. Besides, my hosts file is vast!)
> > > 
> > > Unfortunately, when I try and use mod_headers to set the Host:
> header
> > > for these backend connections, the balancer layer destroys the
> > > result and replaces it with the IP.
> > > 
> > > Apparently, if I switch ProxyPreserveHost on, I may get further,
> > > but since that's a site-wide setting a side effect would mean all
> > 
> > Not quite sure what you mean by site-wide, but:
> >
> http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypreservehost
> > says: Context:  server config, virtual host

In trunk proxypreservehost can be put in *any* context.

> > But ProxySet only allows you to set the same Variables as
> > ProxyPass does. host is none of them.
> 
> Indeed. This appears to be the problem. Such an option is missing.

Right now I'm looking into 2.2's source to see how to add an option
preservehost=(on|off).

Can you please test:
http://people.apache.org/~igalic/patches/mod_proxy-preserve_host.diff

duh.. nodocumentationpatch!
But I'm pretty sure you can guess how to use it ;)

> DFW

i

-- 
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.ga...@brainsware.org
URL: http://brainsware.org/

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



Re: [users@httpd] mod_proxy_balancer - no way to name pool members by IP.

2011-02-04 Thread dfw-apache
On Thu, Feb 03, 2011 at 11:00:25PM +, Igor Gali?? wrote:
> - dfw-apa...@white.u-net.com wrote:
> > I've hit a vexing impasse with mod_proxy_balancer.
> > 
> > I have a pool of backend boxes. They vhost many domains, so
> > need the specific Host: header in requests to them (the *same*
> > Host: header for all of them)
> > 
> > I proxy requests to them potentially thousands of times a second,   
> > and their IP's are not going to be changing, so I name the
> > BalancerMembers by IP address, as the DNS lookup overhead is 
> > a fatal waste of CPU, especially if your DNS servers melt
> > and your site dies unnecessarily. (No, /etc/hosts is not possible.
> 
> http://httpd.apache.org/docs/current/mod/mod_proxy.html#startup

That only mentions ProxyBlock. We do not use ProxyBlock. Also, when we
lost DNS, we lost the site, so reality has the last word regardless.

> > The sitename has multiple A records, and I make the backends choose
> > individualiseable vhosts. Besides, my hosts file is vast!)
> > 
> > Unfortunately, when I try and use mod_headers to set the Host: header
> > for these backend connections, the balancer layer destroys the
> > result and replaces it with the IP.
> > 
> > Apparently, if I switch ProxyPreserveHost on, I may get further,
> > but since that's a site-wide setting a side effect would mean all
> 
> Not quite sure what you mean by site-wide, but:
> http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypreservehost
> says: Context:server config, virtual host

It does. Our site is a vhost. It has squillions of proxypasses to squillions of 
different backend boxes run by squillions of different people. I want to add
another backend without breaking all of the other ones.

> > of my other proxied directories would now get the wrong Host: header.
> > All the RewriteRule [P]'s would break and I would have to catch and
> 
> Wit a sec.
> You're using mod_rewrite for proxying?
> Why? (http://bash.org/?866112)

Because I'm rewriting the URL, and then proxying it? Because I'm using
rewritemaps? Because I like the letter P? Pick one :) Also, this problem
is only using ProxyPass, so mod_rewrite is not the problem here.

> > replace the Host in every single one of them in individual 
> > blocks.
> > That deluge of perpetual kludgery does not appeal.
> > 
> > What I need is a way to tell a ProxyPass or BalancerMember, that
> > they should use a certain Host: header in its communications
> > with this backend. e.g.
> > BalancerMember http://10.0.0.1/foo/ host=foobar.com
> 
> Now I'm confused. How do your configs actually look like?

ProxyPreserveHost Off
ProxyPass /foo/ balancer://www.mybackend1.net/

  ProxySet lbmethod=bybusyness timeout=10
  BalancerMember http://192.168.0.1 lbset=0 retry=0 ttl=5
  BalancerMember http://10.0.0.1lbset=1 retry=0 ttl=5

http://192.168.0.1>
  RequestHeader set Host www.mybackend1.net

http://10.0.0.1>
  RequestHeader set Host www.mybackend1.net

ProxyPass /bar/  http://www.mybackend2.net/
ProxyPass /bar1/ http://www.mybackend3.net/
ProxyPass /bar2/ http://www.mybackend4.net/
...

192.168.0.1 receives 'Host: 192.168.0.1', not the 'Host: www.mybackend1.net' I 
want it to. www.mybackend2.net receives 'Host: www.mybackend2.net' and I want 
to keep it that way.

> > The logical alternative would have been to be able to specify a
> > certain target IP to connect to instead of a certain Host name
> > to use e.g.
> > BalancerMember http://foobar.com/foo/ address=10.0.0.1
> > 
> > but I suspect apache would then be unable to set  block
> > rules for individual balancer members since they'd all declare
> > the same URL and you'd be unable to match them individually
> 
> You can use ProxySet
> http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxyset
> in  and 
> 
> But ProxySet only allows you to set the same Variables as
> ProxyPass does. host is none of them.

Indeed. This appears to be the problem. Such an option is missing.

DFW

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



Re: [users@httpd] mod_proxy_balancer - no way to name pool members by IP.

2011-02-03 Thread Igor Galić

- dfw-apa...@white.u-net.com wrote:

> I've hit a vexing impasse with mod_proxy_balancer.
> 
> I have a pool of backend boxes. They vhost many domains, so
> need the specific Host: header in requests to them (the *same*
> Host: header for all of them)
> 
> I proxy reqeusts to them potentially thousands of times a second,   
> and their IP's are not going to be changing, so I name the
> BalancerMembers by IP address, as the DNS lookup overhead is 
> a fatal waste of CPU, especially if your DNS servers melt
> and your site dies unnecessarily. (No, /etc/hosts is not possible.

http://httpd.apache.org/docs/current/mod/mod_proxy.html#startup

> The sitename has multiple A records, and I make the backends choose
> individualiseable vhosts. Besides, my hosts file is vast!)
> 
> Unfortunately, when I try and use mod_headers to set the Host: header
> for these backend connections, the balancer layer destroys the
> result and replaces it with the IP.
> 
> Apparently, if I switch ProxyPreserveHost on, I may get further,
> but since that's a site-wide setting a side effect would mean all

Not quite sure what you mean by site-wide, but:
http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxypreservehost
says: Context:  server config, virtual host


> of my other proxied directories would now get the wrong Host: header.
> All the RewriteRule [P]'s would break and I would have to catch and

Wit a sec.
You're using mod_rewrite for proxying?
Why? (http://bash.org/?866112)

> replace the Host in every single one of them in individual 
> blocks.
> That deluge of perpetual kludgery does not appeal.
> 
> What I need is a way to tell a ProxyPass or BalancerMember, that
> they should use a certain Host: header in its communications
> with this backend. e.g.
> BalancerMember http://10.0.0.1/foo/ host=foobar.com

Now I'm confused. How do your configs actually look like?

> The logical alternative would have been to be able to specify a
> certain target IP to connect to instead of a certain Host name
> to use e.g.
> BalancerMember http://foobar.com/foo/ address=10.0.0.1
> 
> but I suspect apache would then be unable to set  block
> rules for individual balancer members since they'd all declare
> the same URL and you'd be unable to match them individually

You can use ProxySet
http://httpd.apache.org/docs/current/mod/mod_proxy.html#proxyset
in  and 

But ProxySet only allows you to set the same Variables as
ProxyPass does. host is none of them.


> So, I currently can't use my backends in mod_proxy_balancer
> 
> Does anyone have any suggestions?

Paste(bin) youur config or enough of it, that we can deduce
what you're trying to do and how.
 
> DFW

i

-- 
Igor Galić

Tel: +43 (0) 664 886 22 883
Mail: i.ga...@brainsware.org
URL: http://brainsware.org/

-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org



[users@httpd] mod_proxy_balancer - no way to name pool members by IP.

2011-02-03 Thread dfw-apache
I've hit a vexing impasse with mod_proxy_balancer.

I have a pool of backend boxes. They vhost many domains, so
need the specific Host: header in requests to them (the *same*
Host: header for all of them)

I proxy reqeusts to them potentially thousands of times a second,   
and their IP's are not going to be changing, so I name the
BalancerMembers by IP address, as the DNS lookup overhead is 
a fatal waste of CPU, especially if your DNS servers melt
and your site dies unnecessarily. (No, /etc/hosts is not possible.
The sitename has multiple A records, and I make the backends choose
individualiseable vhosts. Besides, my hosts file is vast!)

Unfortunately, when I try and use mod_headers to set the Host: header
for these backend connections, the balancer layer destroys the
result and replaces it with the IP.

Apparently, if I switch ProxyPreserveHost on, I may get further,
but since that's a site-wide setting a side effect would mean all
of my other proxied directories would now get the wrong Host: header.
All the RewriteRule [P]'s would break and I would have to catch and
replace the Host in every single one of them in individual  blocks.
That deluge of perpetual kludgery does not appeal.

What I need is a way to tell a ProxyPass or BalancerMember, that
they should use a certain Host: header in its communications
with this backend. e.g.
BalancerMember http://10.0.0.1/foo/ host=foobar.com

The logical alternative would have been to be able to specify a
certain target IP to connect to instead of a certain Host name
to use e.g.
BalancerMember http://foobar.com/foo/ address=10.0.0.1

but I suspect apache would then be unable to set  block
rules for individual balancer members since they'd all declare
the same URL and you'd be unable to match them individually

So, I currently can't use my backends in mod_proxy_balancer

Does anyone have any suggestions?

DFW


-
The official User-To-User support forum of the Apache HTTP Server Project.
See http://httpd.apache.org/userslist.html> for more info.
To unsubscribe, e-mail: users-unsubscr...@httpd.apache.org
   "   from the digest: users-digest-unsubscr...@httpd.apache.org
For additional commands, e-mail: users-h...@httpd.apache.org