LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Software (https://www.linuxquestions.org/questions/linux-software-2/)
-   -   apache vhost problem (https://www.linuxquestions.org/questions/linux-software-2/apache-vhost-problem-286869/)

jelgavchik 02-06-2005 07:25 AM

apache vhost problem
 
Hello.
First i will explain the structure of my small home lan. So i have router which is also a firewall and a real ip asigned to it for ext eth0 + internal eth1 and 192.168.1.1 ip asigned to it. Now i have domain register to my external ip - domain.com. But now the problem is that i run apache server on one of machines on my internal lan with ip 192.168.1.10. I have configured iptables script on my router so everything works fine, i can browse ''mydomain.com'' from my internal newtwork and people from internet can do. But i want to run virtual hosts for example "harmonyofsoul.mydomain.com" (this subdomain is registered also to my external addresse) on the same apache and on the same interface with ip 192.168.1.10. When i do this in the right section of my httpd.conf, and restarted the server i still get what i have in my /var/www/htdocs

This is what i write in my httpd.con:

NameVirtualHost 192.168.1.10:80

<VirtualHost 192.168.1.10:80>
DocumentRoot /var/www/harmonyofsoul
ServerName harmonyofsoul.mydomain.com
</VirtualHost>

Still no result am getting what i have in my /var/www/htdocs

How can i fix this problem?

QtCoder 02-15-2005 10:07 PM

In Apache, you have to have a virtual host for all sites, including your primary /var/www/htdocs site. For example:

Code:

NameVirtualHost *:80

<VirtualHost *:80>
DocumentRoot /var/www/htdocs
ServerName mydomain.com
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /var/www/harmonyofsoul
ServerName harmonyofsoul.mydomain.com
</VirtualHost>

For the first virtual host container, just copy the directives directly from your global configuration. You only need those two for it to work. Yeah, I know ... seems rather redundant. But, it's required.

Hope this helps a little. If not, check here http://httpd.apache.org/docs-2.0/vhosts/name-based.html for Apache 2 docs, or here: http://httpd.apache.org/docs/vhosts/name-based.html for Apache 1 docs.

QtCoder 02-15-2005 10:10 PM

EDIT: I just deleted what I wrote. I'm getting ahead of myself..... ignore this second post of mine :o

KrisRoberts 04-27-2008 04:05 AM

I'm trying to get something very similar working.

I have a static internet addressable IP.
We have several domain names for which we control the DNS.
My Apache server is behind a Netgear FR114P firewall.
The firewall is forwarding all http traffic to the Apache server.

No matter which name we use on the outside of the firewall, we get sent to the same VirtualServer.

Looking at the logs in the firewall, the traffic all appears with only the IP (no domain names). My hunch is that the names are stripped out be fore the Apache server gets hit, so all its seeing are the IPs and cant do the name based virtual host re-direction.

I've poked all around the options in the firewall and dont see anything obvious to keep and pass the domain name along to the server.

Is it possible to do this sort of thing, or do I need to put the web server outside the firewall?

Thanks!

Quote:

Originally Posted by jelgavchik (Post 1454434)
...So i have router which is also a firewall and a real ip asigned to it for ext eth0 + internal eth1 and 192.168.1.1 ip asigned to it. Now i have domain register to my external ip - domain.com. But now the problem is that i run apache server on one of machines on my internal lan with ip 192.168.1.10. I have configured iptables script on my router so everything works fine, i can browse ''mydomain.com'' from my internal newtwork and people from internet can do. But i want to run virtual hosts for example "harmonyofsoul.mydomain.com" (this subdomain is registered also to my external addresse) on the same apache and on the same interface with ip 192.168.1.10. When i do this in the right section of my httpd.conf, and restarted the server i still get what i have in my /var/www/htdocs
?


KrisRoberts 04-27-2008 04:45 PM

The docs do explain it, but it took me finding a post another forum to really understand.
http://httpd.apache.org/docs/2.0/mod...amevirtualhost

Quote:

In cases where a firewall or other proxy receives the requests and forwards them on a different IP address to the server, you must specify the IP address of the physical interface on the machine which will be servicing the requests. If you have multiple name-based hosts on multiple addresses, repeat the directive for each address.
So only one NameVirtualHost with the private IP of the server on the LAN side of the router.

Individual VirtualHost blocks, all with that same IP but the Servername and DocumentRoot appropriate for each of the separate domains.

It works just fine.


All times are GMT -5. The time now is 06:55 AM.