Gossamer Forum
Home : Products : Gossamer Links : Discussions :

"Back End" server problem

Quote Reply
"Back End" server problem
Hi:

I have my back-end server up and riunning fine. Great trick- thanks!

However, I just noticed on small problem. All the Hits and Ratings URL's are being attributed to the IP of my FRONT-END server!

I figure if it does this for me, it must do it for all the other people who do this, too. And there must be a solution.

Anyone know how to fix this?

Had one other FES/BES question. Is it possible to take the BES "off-line?" That is, make it ONLY visible to the front-end server, but not to the web at large? I put mine in at www.bcdb.com:8080, and I had to open a hole in the firewall at 8080 to make it work. There must be some way of instead of using the server name, to do something to tell it to look on the local box, so I can close that port to the world...

Thanks!
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] "Back End" server problem In reply to
Hi,

For the IP issue, see:

http://perl.apache.org/...r_in_the_Proxy_Setup

For the port question, change your proxypass to be:

http://localhost:8080/

and that should work with your firewall up.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] "Back End" server problem In reply to
Oh, and you can skip the Build section about recompiling Apache with the custom module if you are using I believe 1.3.24 or later of Apache.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] "Back End" server problem In reply to
Alex:

Thank you for both.

I am confused. You wrote:

Oh, and you can skip the Build section about recompiling Apache with the custom module if you are using I believe 1.3.24 or later of Apache.


I am using 1.3.27, so I do NOT have to compile it into apache? I just have to save it somewhere? Sorry, nebie confusion.... where would I save it? Or is it ALREADY built into apache, and I only have to call it? (Sorry ! Blush)
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] "Back End" server problem In reply to
If you have 1.3.27, then you only need to do the part under Usage, skip the part in build.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] "Back End" server problem In reply to
Thanks Alex!

Will get that added today.

Another quick question on this subject, if I may. My BES has a Links directory and a Forum directory, accessed as www.bcdb.com:8080 and forum.bcdb.com:8080

Do I make the path to BOTH http://localhost:8080/, or should I have www.bcdb.com listen to 8080 and forum to 8081? (I am just wonderoing if I need to seperate them since there is nothing in localhost to say which server to open...)
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] "Back End" server problem In reply to
OK, another question...

I TRIED to follow the instructions on the page you referenced closely, but I must be doing SOMETHING wrong, because I am gettiing a 500 Internal Server Error. Here is the error from the Logs:

[Thu Jun 19 11:40:08 2003] [error] Can't locate My/ProxyRemoteAddr.pm in @INC (@INC contains: ../.. /hd2/web/c/cartoon/public_html/bcdb/admin /hd2/web/f/forum/public_html/forum/admin /usr/local/lib/perl5/5.8.0/i386-freebsd /usr/local/lib/perl5/5.8.0 /usr/local/lib/perl5/site_perl/5.8.0/i386-freebsd /usr/local/lib/perl5/site_perl/5.8.0 /usr/local/lib/perl5/site_perl/5.005 /usr/local/lib/perl5/site_perl /usr/local/apache/ . /usr/test/apache/ /usr/test/apache/lib/perl) at (eval 716) line 3.

[Thu Jun 19 11:40:08 2003] [error] Undefined subroutine &My::ProxyRemoteAddr::handler called.

[Thu Jun 19 11:40:08 2003] [error] Undefined subroutine &My::ProxyRemoteAddr::handler called.

At first, I thought it might be that the modu;le might not exist in my apache, so I compiled mod_proxy_add_forward.c in. Still the error.

So the next step says:

If you are using Apache::Registry or Apache::PerlRun modules just put the following code into startup.pl:

I checked, and both those modules are part of mod_perl 1.27, so I have those in. by "add the code to startup.pl, I ASSUME they mean my mod_perl startup file, right? That looks like:

### Forward IP addy

use Apache::Constants ();

sub My::ProxyRemoteAddr ($) {

my $r = shift;

# we'll only look at the X-Forwarded-For header if the requests

# comes from our proxy at localhost

return Apache::Constants::OK

unless ($r->connection->remote_ip eq "127.0.0.1")

and $r->header_in('X-Forwarded-For');

# Select last value in the chain -- original client's ip

if (my ($ip) = $r->headers_in->{'X-Forwarded-For'} =~ /([^,\s]+)$/) {

$r->connection->remote_ip($ip);

}

return Apache::Constants::OK;

}



use lib '/hd2/web/f/forum/perl/forum/admin';

use GForum::mod_perl;

use lib '/hd2/web/c/cartoon/public_html/bcdb/admin';

use Links::mod_perl;

#PerlSendHeader On;

1; #return true value



So I added that code in. And it starts up fine, it seems like. But when I add the "PerlPostReadRequestHandler My::ProxyRemoteAddr" to httpd.conf, I get the server error...

Where did I go wrong?


dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] "Back End" server problem In reply to
In your frontend I would do:

ProxyPass /bcdb/ http://localhost:8080/bcdb/
ProxyPassReverse /bcdb/ http://localhost:8080/bcdb/

and in the forum virtualhost:

ProxyPass /forum/ http://localhost:8080/forum/
ProxyPass /forum/ http://localhost:8080/forum/

and then in your backend:

Alias /bcdb/ /path/to/links-sql/
Alias /forum/ /path/to/gforum/
<Directory /path/to/links-sql/>
SetHandler perl-script
PerlHandler Apache::Registry
PerlSendHeader On
Options ExecCGI
</Directory>
<Directory /path/to/forum/>
.. same thing
</Directory>

That way you can keep it all on one port.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [carfac] "Back End" server problem In reply to
Make sure you have your:

PerlRequire /path/to/startup.pl

before your:

PerlPostReadRequestHandler My::ProxyRemoteAddr

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] "Back End" server problem In reply to
Alex,

In earlier versions of apache (like what I was using), I needed load a few extra modules, and a small script to use the proxypassreverse properly. I can't remember what it was.

Also, security. Doesn't the proxy server need to set up to only accept requests from the localhost proxy?

Just curious. I know a lot has changed in the past year or two.


PUGDOG� Enterprises, Inc.

The best way to contact me is to NOT use Email.
Please leave a PM here.
Quote Reply
Re: [Alex] "Back End" server problem In reply to
Alex:

Thanks- proxy works fine!

RE the IP Pass thing, this is from httpd.conf:

<Location /bcdb>
SetHandler perl-script
PerlHandler Apache::Registry
PerlSendHeader On
Options +ExecCGI
PerlRequire /hd2/web/c/cartoon/startup.pl
</Location>


# PerlPostReadRequestHandler My::ProxyRemoteAddr

So I have them in the right order.... (I have it commented out right now for obvious reasons!)
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] "Back End" server problem In reply to
Try:

PerlRequire /hd2/web/c/cartoon/startup.pl
PerlPostReadRequestHandler My::ProxyRemoteAddr

<Location /bcdb>
SetHandler perl-script
PerlHandler Apache::Registry
PerlSendHeader On
Options +ExecCGI
</Location>

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [pugdog] "Back End" server problem In reply to
Quote:
In earlier versions of apache (like what I was using), I needed load a few extra modules, and a small script to use the proxypassreverse properly. I can't remember what it was.

The small script is the one described which sets the IP properly. The module is mod_proxy, and before Apache 1.3.24, you also need a custom mod_proxy_add_forward.c file, but ths is now part of Apache.

Quote:
Also, security. Doesn't the proxy server need to set up to only accept requests from the localhost proxy?

Just curious. I know a lot has changed in the past year or two.

No, it isn't really a security risk to be open, as users are connecting to it anyway. It would be a good idea to lock it down, but not essential.

Cheers,

Alex
--
Gossamer Threads Inc.
Quote Reply
Re: [Alex] "Back End" server problem In reply to
Alex:

No joy with the new order... Unsure still getting the same error.
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] "Back End" server problem In reply to
Well, I GOT it working, and it was not easy!

The think that stuck out to me was the error saying it could not find the sub "handler"- and there is no sub in the routine CALLED handler... I do not know if that makkers, but it stuck out to me.

So I reworked the code a bit and made it "Apache::ProxyRemoteAddr" Then I did not need to call it via the startup file, it owuld be there already.

Then I changed PerlPostReadRequestHandler My::ProxyRemoteAddr to PerlPostReadRequestHandler Apache::ProxyRemoteAddr

and I restarted. Still did not work. So, I changed the line unless ($r->connection->remote_ip eq "127.0.0.1")
in the code to: unless ($r->connection->remote_ip eq "My.actual.IP.addy")


And NOW it works!!!

It was a mess, so I thought I woulfd share with you what I did...

dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] "Back End" server problem In reply to
Whoops! Need some help!

I need that edited linke to show two IP's, not just one. I tried this:

unless ($r->connection->remote_ip eq "66.219.198.201|66.219.198.207")

and that does not seem to work. How do I get an "OR" in there? Maybe like this:

unless ($r->connection->remote_ip eq "66.219.198.201" | "66.219.198.207")

Sorry, not so hot on the perl!

dave
dave

Big Cartoon DataBase
Big Comic Book DataBase
Quote Reply
Re: [carfac] "Back End" server problem In reply to
OK, got it! Bit of a workaround, but I just made a second whole script, called it

Apache::ProxyRemoteAddr1

and put the second call in the forum folder.... used one for Links, the second for forum.


dave

Big Cartoon DataBase
Big Comic Book DataBase