Click to See Complete Forum and Search --> : Two Internal Web Servers, One IP Address


nko
05-06-2008, 02:28 PM
Hello,

I have several computers at home, most of which are "servers" (they're home servers hosting content that is infrequently accessed by a handful of people, so I can play around with my network without worry). I have a dynamic DNS service pointing a few different records at my single IP.

I have two Apache2 web servers: web1 and web2. web1 is currently providing content just fine, and in fact a while back I configured a virtual host so it's actually hosting two different sites. Now, I've got a cool database with a web frontend on web2. I'd like web1 to forward requests for yet another URL to web2. I've tried some stuff with mod_proxy (http://www.schirrms.net/sme/SMEApacheReverseProxy.php , http://httpd.apache.org/docs/1.3/mod/mod_proxy.html , etc) yet when I go to the corresponding URL, I get the default page for web1 instead of anything from web2.

I'm running Debian 4 on both servers.

My listing for mods-enabled:


alias.load authz_default.load autoindex.load dav_fs.load env.load proxy_connect.load status.load
auth_basic.load authz_groupfile.load cgid.conf dav.load mime.load proxy_http.load
auth_digest.load authz_host.load cgid.load dir.conf negotiation.load proxy.load
authn_file.load authz_user.load dav_fs.conf dir.load proxy.conf setenvif.load


My "proxy_site" in /etc/apache2/sites-enabled:

<VirtualHost nkoweb2.no-ip.biz>
ServerName nkoweb2.no-ip.biz
ServerAlias 192.168.0.198
ProxyPreserveHost On
ProxyPass / http://192.168.0.198/
ProxyPassReverse / http://192.168.0.198/
</VirtualHost>


(I've changed my URLs to fake ones here for whatever reason). I've also tried using internal hostnames instead of internal IP addresses.

This is one of those things where the issue is that I don't understand how my idea of what I want to do maps to what Apache can actually make happen (and how it goes about it) so if I need to make more sense, please let me know!

bwkaz
05-06-2008, 07:14 PM
Have you tried checking out the Apache 2.2 docs, here?:

http://httpd.apache.org/docs/2.2/mod/mod_proxy.html

(Also, have you followed the recommendation of securing the server before turning on proxying? Maybe it doesn't apply in your case though. Oh, never mind, it doesn't: reading more of that page, it's less of a problem when you do reverse proxying. See below.)

You want a reverse proxy (according to the 2.2 documentation page's definitions), not a forward proxy. You will want to disable mod_proxy_connect (since you're using a reverse proxy; the CONNECT verb is only useful for a forward proxy). You will probably also want to ensure that ProxyRequests is set to off. You may also want to see if you can find a Debian package for mod_proxy_html (http://apache.webthing.com/mod_proxy_html/), as the existing mod_proxy and mod_proxy_http won't rewrite URLs inside HTML documents (only inside certain HTTP headers).

Last, if none of that helps, it might be a good idea to grab a packet capture (on both NICs of the proxying machine) when you make a request. That way you can see exactly what's being requested on both sides (and whether there's any request at all being sent to the internal web server). Also, it may help to increase that VirtualHost's LogLevel, if some error is happening (that may give you more info in the error log).

nko
05-07-2008, 11:41 AM
I suppose I should read the documentation for the right version of Apache! Will try that and report back...

nko
05-08-2008, 11:36 AM
That totally worked. Thanks! I now have:


ProxyRequests Off
ProxyPass /foo http://web2/
ProxyPassReverse /foo http://web2


I'm sure some of that is superfluous and I still need to make proxy_html work. I'll post my final solution when I get it in place. Again, thanks!