View previous topic :: View next topic |
Author |
Message |
tkhobbes Guru
Joined: 12 Nov 2004 Posts: 367 Location: Switzerland
|
Posted: Mon Aug 08, 2005 6:43 pm Post subject: Apache listening to two different host-addresses |
|
|
Hi all
Please forgive any dumb question, but I am quite new to Apache and was a little confused by all the docs available, so I thought I'd ask here.
Here's my scenario: I have a Gentoo box acting as a server for my home-lan. It has apache running and is listening to both 10.10.10.10 and some dns name like linux.homenetwork.own - working perfectly from my home-lan.
The box is behind a router which has port 80 forwarded to it; when I type the public IP of my router on any computer not in my home-lan, I come to the default apache page of my Gentoo server.
So far, so good.
What I now want is apache jumping into some other virtual root directory when I access the box via the public IP (which has also some dyndns-domain assigned to it).
Can I do that? How do I do that?
Thanks for any help!
thomas _________________ My systems and some screenshots: http://www.hobbes.ch/techie/
My Gentoo client installation page: http://www.hobbes.ch/techie/gentoo-client/
My Gentoo Server installation: http://www.hobbes.ch/category/server |
|
Back to top |
|
|
ekutay l33t
Joined: 30 Mar 2005 Posts: 636 Location: Berlin
|
Posted: Mon Aug 08, 2005 6:49 pm Post subject: |
|
|
Quote: | .. virtual root directory... | As you have named it, you are very close. You setup a virtual host, with the given IP adress or dyndns hostname as ServerName. You may almost specify anything in a virtual host context, that you can setup for the main config, thus you can set your virtual directory here as DocumentRoot. _________________ -- erol |
|
Back to top |
|
|
tkhobbes Guru
Joined: 12 Nov 2004 Posts: 367 Location: Switzerland
|
|
Back to top |
|
|
ekutay l33t
Joined: 30 Mar 2005 Posts: 636 Location: Berlin
|
Posted: Mon Aug 08, 2005 8:20 pm Post subject: |
|
|
That's clear. But you don't want to setup a complete server, just a virtual host in apache.
Have a look at the apache docs, but note, that the setup is somehow preconfigured on gentoo. http://httpd.apache.org/docs/2.0/vhosts/
On gentoo running an apache2 for instance, you should have a directory /etc/apache2/vhosts.d and a file called 00default_vhost.conf. Setup one additional file or use the default one and change the parameters suiting your needs. Could be something like:
Quote: | <VirtualHost 123.123.123.123:80>
ServerAdmin foo@bar.de
DocumentRoot /var/www/my_virtual_directory_for_external_access
<Directory /var/www/my_virtual_directory_for_external_access>
...
..
.
</Directory>
ErrorLog /var/log/apache2/123.123.123/error_log
AccessLog /var/log/apache2/123.123.123/access_log
</VirtualHost> | If you have a domain you can use a NamedVirtualHost too or set the ServerName directive and so on. Check the apache configs for that and play around. _________________ -- erol |
|
Back to top |
|
|
tkhobbes Guru
Joined: 12 Nov 2004 Posts: 367 Location: Switzerland
|
Posted: Thu Aug 11, 2005 6:23 am Post subject: |
|
|
Hi there
Thanks for the tip - I tried to set up a virtual host (btw, the config files are in /etc/apache2/conf/vhosts, the file's name is vhosts.conf) according to the official apache2-doc.
Now, what works is the same as before - when entering the dyndns-domainname from any client outside my homelan, I end up on apache's default page - as expected.
But I installed squirrelmail, when I now type in myalias.dyndns.org/squirrelmail I get an error message complaining about "linux.homenetwork.own could not be found" - so apparently, somehow my box is not resolving dns names correctly.
I have absolutely no clue what I have to do now - there is no hostname set in the squirrelmail config, do I have to alter the /etc/hosts file somehow?
Help!
EDIT: Here is my vhosts.conf file (x.x.x.x is my public IP):
Code: |
NameVirtualHost 10.10.10.10
NameVirtualHost x.x.x.x
<VirtualHost 10.10.10.10>
DocumentRoot /var/www/localhost/htdocs
ServerName linux.homenetwork.own
</VirtualHost>
<VirtualHost x.x.x.x>
DocumentRoot /var/www/localhost/htdocs
ServerName myalias.dyndns.org
</VirtualHost>
NameVirtualHost 10.10.10.10:443
|
_________________ My systems and some screenshots: http://www.hobbes.ch/techie/
My Gentoo client installation page: http://www.hobbes.ch/techie/gentoo-client/
My Gentoo Server installation: http://www.hobbes.ch/category/server |
|
Back to top |
|
|
|