[Catalyst] Anyone using ProxyPass?
Richard Jones
ra.jones at dpw.clara.co.uk
Tue Jul 3 17:36:53 GMT 2007
Bill Moseley wrote:
> On Tue, Jul 03, 2007 at 11:24:34AM +0100, Richard Jones wrote:
>> 1) There is definitely no $c->request->header('X-Forwarded-Host')
>
> Check if you have X-Forwarded-For.
>
Nope, no X-Forwarded-Anything! But I *do* see it in a dump of Apache's
headers if I request the base url (ie http://server.ip.address/myapp),
which generates the 'Welcome to Catalyst' default page, as I don't have
anything on that url. If I request a genuine page eg
http://server.ip.address/myapp/search, then all X-Forwarded-* entries
disappear from $self->apache->headers_in and $c->request->headers.
> Let's see, I have not looked at this in a while but in apache2 I
> have:
>
> LoadModule proxy_module /usr/lib/apache2/modules/mod_proxy.so
> LoadModule proxy_http_module
> /usr/lib/apache2/modules/mod_proxy_http.so
It looks like the way I installed the backend Apache was to use
statically-linked modules, as a) there no list of LoadModules like in my
front-end httpd.conf, and b) I get them all displayed if I do:
/usr/local/apache2/bin/httpd -l eg mod_proxy.c
> ProxyVia On ProxyReceiveBufferSize 16384
I don't have either of those set.
> I guess I'm using mod_rewrite to figure out what does or doesn't need
> to be sent to the back end -- so after all my rewrite rules and
> conditions I have:
>
> # Proxy everything else RewriteRule (.+) http://127.0.0.1:10085$1
> [proxy]
>
> After that I guess you are stuck figuring out why you are not getting
> that header.
I don't use RewriteRule - my understanding is that with Apache 2.2.x
mod_rewrite is not needed, just mod_proxy, though as you will have
guessed, I'm not Apache expert!
>
>> 2) In Catalyst::Engine::Apache::prepare_path, $host = the IP
>> address of the server (not localhost or 127.0.0.1), and $port = 81.
>>
>
> Did you see this code?
>
> PROXY_CHECK: { my $headers = $self->apache->headers_in; unless (
> $c->config->{using_frontend_proxy} ) { last PROXY_CHECK if
> $c->request->address ne '127.0.0.1'; last PROXY_CHECK if
> $c->config->{ignore_frontend_proxy}; } last PROXY_CHECK unless
> $headers->{'X-Forwarded-For'};
>
> # If we are running as a backend server, the user will always appear
> # as 127.0.0.1. Select the most recent upstream IP (last in the list)
> my ($ip) = $headers->{'X-Forwarded-For'} =~ /([^,\s]+)$/;
> $c->request->address( $ip ); }
>
> If your address isn't 127.0.0.1 then it's not going to check for a
> proxy unless "using_frontend_proxy" is set.
>
Yes I saw that, and realised that it would 'last PROXY_CHECK' as the
address wasn't localhost. Basically if I 'trick' the system by manually
setting $c->request->header('X-Forwarded-Host' =>
'ip.address.of.frontend') and $host to 'localhost' then I get the
desired effect in the Catalyst app's URL's.
But it sounds like this is an Apache setup issue rather than Catalyst,
and though I am most grateful for your help, perhaps I should ask on an
Apache forum? (I only subscribe to the mod_perl mailing list though).
--
Richard Jones
More information about the Catalyst
mailing list