Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 217
  • Last Modified:

Odd Virtual Host Behavior

I've got several domains that point to the same IP.  Running Apache on that IP.

Here is what the section of httpd.conf looks like (note: IPs and domain names have been changed to protect the ignorant):

[CODE]
DocumentRoot "/usr/local/apache/htdocs"

....
....

NameVirtualHost *
NameVirtualHost !!!.!!!.!!!.!!!
ServerName domain1.com

<VirtualHost *:80>
DocumentRoot "/usr/local/apache/htsisters"
<Directory "/usr/local/apache/htsisters">
allow from all
Options +Indexes
</Directory>
ServerName domain2.net
</VirtualHost>

<VirtualHost domain3.net:80>
DocumentRoot /usr/local/apache/htbmnet
<Directory "/usr/local/apache/htbmnet">
allow from all
Options +Indexes
</Directory>
ServerName domain3.net
</VirtualHost>
[/CODE]

Now domain2 is not pointing properly at this time, so I don't know what its behavior is.  However when I browse to domain1.com, I get the pages for domain3.net.  I also get the pages for domain3.net when I browse to domain3.net.

I am having extreme trouble getting this to work  . . .
0
WarriorPoet42
Asked:
WarriorPoet42
  • 8
  • 4
1 Solution
 
mrielfCommented:
Our httpd.conf is looks like this (I modified it for your needs) and works fine:


*********************************
ServerName localhost
ServerAdmin webmaster@domain1.net
DocumentRoot /usr/local/apache/htdocs


NameVirtualHost xxx.xxx.xxx.xxx

<VirtualHost xxx.xxx.xxx.xxx>
    ServerAdmin webmaster@domain2.net
    DocumentRoot /usr/local/apache/htsisters
    ServerName domain2.net
    ServerAlias domain2.net
</VirtualHost>

<VirtualHost xxx.xxx.xxx.xxx>
    ServerAdmin webmaster@domain3.net
    DocumentRoot /usr/local/apache/htbmnet
    ServerName www.domain3.net
    ServerAlias domain3.net
</VirtualHost>

<VirtualHost _default_:*>
    ServerAdmin webmaster@domain1.net
    DocumentRoot /usr/local/apache/htdocs
</VirtualHost>
*********************************

Domain2 and Domain3 are named only, and all unknow domain will go to domain1 home...

0
 
mrielfCommented:
A little bug in first VirtualHost section:

ServerName www.domain2.net

:)
0
 
WarriorPoet42Author Commented:
OK, used your code.

Now what happens is domain1 shows me domain3's files

Domain2 shows the correct files

And, as I said, I cannot test what domain3 would show me.  Yet.
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
mrielfCommented:
stupid question, but apache server was restarted?
0
 
WarriorPoet42Author Commented:
Not a stupid question.  But an easy answer: aye.
0
 
mrielfCommented:
Then I have no idea why this server works this way...
0
 
mrielfCommented:
Try to place a VirtualHost definition for domain1 too...

*********************************
ServerName localhost
ServerAdmin webmaster@domain1.net
DocumentRoot /usr/local/apache/htdocs


NameVirtualHost xxx.xxx.xxx.xxx

<VirtualHost xxx.xxx.xxx.xxx>
    ServerAdmin webmaster@domain1.net
    DocumentRoot /usr/local/apache/htsisters
    ServerName www.domain1.net
    ServerAlias domain1.net
</VirtualHost>

<VirtualHost xxx.xxx.xxx.xxx>
    ServerAdmin webmaster@domain2.net
    DocumentRoot /usr/local/apache/htsisters
    ServerName www.domain2.net
    ServerAlias domain2.net
</VirtualHost>

<VirtualHost xxx.xxx.xxx.xxx>
    ServerAdmin webmaster@domain3.net
    DocumentRoot /usr/local/apache/htbmnet
    ServerName www.domain3.net
    ServerAlias domain3.net
</VirtualHost>

<VirtualHost _default_:*>
    ServerAdmin webmaster@domain1.net
    DocumentRoot /usr/local/apache/htdocs
</VirtualHost>
*********************************
0
 
mrielfCommented:
Eh copy/paste... of course another mistake... :)

<VirtualHost xxx.xxx.xxx.xxx>
    ServerAdmin webmaster@domain1.net
    DocumentRoot /usr/local/apache/htdocs
    ServerName www.domain1.net
    ServerAlias domain1.net
</VirtualHost>


0
 
mrielfCommented:
And if www.domain1.net still serve domain3.net files, then please look at your /usr/local/apache/htdocs directory and compare it to /usr/local/apache/htbmnet maybe files identical at both places....
0
 
WarriorPoet42Author Commented:
This appears to work.  However I cannot test the final domain.  Do before I give you the points, can I post to this question after the points have been awarded?
0
 
mrielfCommented:
yes
0
 
WarriorPoet42Author Commented:
I /will/ report after DNS gets fixed.  Thank you very much, mrielf.
0

Featured Post

Get quick recovery of individual SharePoint items

Free tool – Veeam Explorer for Microsoft SharePoint, enables fast, easy restores of SharePoint sites, documents, libraries and lists — all with no agents to manage and no additional licenses to buy.

  • 8
  • 4
Tackle projects and never again get stuck behind a technical roadblock.
Join Now