LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 02-06-2005, 07:25 AM   #1
jelgavchik
Member
 
Registered: Dec 2004
Location: Latvia
Distribution: slackware
Posts: 77

Rep: Reputation: 15
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?
 
Old 02-15-2005, 10:07 PM   #2
QtCoder
Member
 
Registered: Aug 2003
Location: USA
Distribution: Slackware 12.0 RC1
Posts: 129

Rep: Reputation: 15
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.

Last edited by QtCoder; 02-15-2005 at 10:14 PM.
 
Old 02-15-2005, 10:10 PM   #3
QtCoder
Member
 
Registered: Aug 2003
Location: USA
Distribution: Slackware 12.0 RC1
Posts: 129

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

Last edited by QtCoder; 02-15-2005 at 10:12 PM.
 
Old 04-27-2008, 04:05 AM   #4
KrisRoberts
LQ Newbie
 
Registered: Apr 2008
Posts: 14

Rep: Reputation: 0
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 View Post
...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
?

Last edited by KrisRoberts; 04-27-2008 at 08:22 AM.
 
Old 04-27-2008, 04:45 PM   #5
KrisRoberts
LQ Newbie
 
Registered: Apr 2008
Posts: 14

Rep: Reputation: 0
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.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Apache: Alias is working on ssl vhost but not on mass vhost jonavogt Linux - Software 0 06-07-2005 02:05 PM
vhost in apache jelgavchik Linux - Networking 3 02-07-2005 06:41 PM
Apache 2 vhost and permissions basse- Linux - Software 1 04-05-2004 07:48 AM
apache 1.3 vhost z4Rilla Linux - Software 0 08-03-2003 06:44 AM
Odd Apache VHost Problem LinuxDude Linux - Software 2 03-13-2003 09:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:05 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration