Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 16 Jul 2003 14:47:15 -0600
From:      Patrick C <patrick@filespanker.com>
To:        freebsd-ipfw@FreeBSD.ORG, freebsd-stable@FreeBSD.ORG
Subject:   accessing a jail via localhost
Message-ID:  <200307161447.15141.patrick@filespanker.com>

next in thread | raw e-mail | index | archive | help
I'm facing a problem with accessing a HTTPd (Apache) jail locally. Consider 
this jail scenario:

/etc/hosts:
127.0.0.1 localhost foo.com
172.16.0.1 apache

/etc/natd.conf:
use_sockets yes
same_ports yes
unregistered_only yes
redirect_port tcp 172.16.0.1:80 80
redirect_port tcp 172.16.0.1:443 443

/etc/firewall.sh
...
${fwcmd} add divert natd all from any to any via ${oif}(IPFW)
...

rl0, my external net inferface, is aliased to 172.16.0.1. Apache 1.3 is 
installed in /usr/jail/httpd. There are <VirtualHost> directives for 5 
different hosts, one of them is foo.com.

The problem is created by the fact that the hostname of this system is 
"foo.com", aliased to 127.0.0.1 in /etc/hosts. If I try to access the httpd 
with http://172.16.0.1/, the page for foo.com doesn't appear, only the 
default page for Apache ("Welcome to Apache!"). However, http://foo.com/ can 
be accessed remotely because natd will actually forward it to the jail if the 
request originates outside of this machine.

If it were as easy as changing foo.com to 172.16.0.1 in the hosts file, I 
would, but other services are dependent on the hostname. I've also tried this 
rule with IPFW:

{fwcmd} add fwd 172.16.0.2,80 tcp from any to localhost 80

...any suggestions? Help is very much appreciated.


Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200307161447.15141.patrick>