Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Im trying to transfer my domain name from godaddy, to a new host (VPS). The new host (VPS) will host 2 domain names (www.A.com, and www.B.com). Using Virtualmin (a webmin module), I created two virtual servers.

My Apache http.conf (virtual Host sections)(Server IP in this example = 111.222.333.444):

    /etc/httpd/conf/http.conf
<VirtualHost 111.222.333.444:80>
SuexecUserGroup "#502" "#502"
ServerName B.com
ServerAlias www.B.com
ServerAlias webmail.B.com
ServerAlias admin.B.com
DocumentRoot /var/www/html/B
ErrorLog /var/log/virtualmin/B.com_error_log
CustomLog /var/log/virtualmin/B.com_access_log combined
ScriptAlias /cgi-bin/ /home/B/cgi-bin/
ScriptAlias /awstats/ /home/B/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /var/www/html/B>
Options -Indexes +IncludesNOEXEC +FollowSymLinks +ExecCGI
allow from all
AllowOverride All
AddHandler fcgid-script .php
AddHandler fcgid-script .php5
FCGIWrapper /home/B/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/B/fcgi-bin/php5.fcgi .php5
</Directory>
<Directory /home/B/cgi-bin>
allow from all
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.B.com
RewriteRule ^(.*) https://B.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.B.com
RewriteRule ^(.*) https://B.com:10000/ [R]
RemoveHandler .php
RemoveHandler .php5
IPCCommTimeout 31
FcgidMaxRequestLen 1073741824
Alias /dav /home/B/public_html
Alias /pipermail /var/lib/mailman/archives/public
<Location /dav>
DAV on
AuthType Basic
AuthName "B.com"
AuthUserFile /home/B/etc/dav.digest.passwd
Require valid-user
ForceType text/plain
Satisfy All
RemoveHandler .php
RemoveHandler .php5
RewriteEngine off
</Location>
<Files awstats.pl>
AuthName "B.com statistics"
AuthType Basic
AuthUserFile /home/B/.awstats-htpasswd
require valid-user
</Files>
RedirectMatch /cgi-bin/mailman/([^/\.]*)(.cgi)?(.*) https://B.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$3
RedirectMatch /mailman/([^/\.]*)(.cgi)?(.*) https://B.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$3
</VirtualHost>
<VirtualHost 111.222.333.444:443>
SuexecUserGroup "#502" "#502"
ServerName B.com
ServerAlias www.B.com
ServerAlias webmail.B.com
ServerAlias admin.B.com
DocumentRoot  /var/www/html/B
ErrorLog /var/log/virtualmin/B.com_error_log
CustomLog /var/log/virtualmin/B.com_access_log combined
ScriptAlias /cgi-bin/ /home/B/cgi-bin/
ScriptAlias /awstats/ /home/B/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /var/www/html/B>
Options -Indexes +IncludesNOEXEC +FollowSymLinks +ExecCGI
allow from all
AllowOverride All
AddHandler fcgid-script .php
AddHandler fcgid-script .php5
FCGIWrapper /home/B/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/B/fcgi-bin/php5.fcgi .php5
</Directory>
<Directory /home/B/cgi-bin>
allow from all
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.B.com
RewriteRule ^(.*) https://B.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.B.com
RewriteRule ^(.*) https://B.com:10000/ [R]
RemoveHandler .php
RemoveHandler .php5
IPCCommTimeout 31
FcgidMaxRequestLen 1073741824
SSLEngine on
SSLCertificateFile /home/B/ssl.cert
SSLCertificateKeyFile /home/B/ssl.key
Alias /dav /home/B/public_html
Alias /pipermail /var/lib/mailman/archives/public
<Location /dav>
DAV on
AuthType Basic
AuthName "B.com"
AuthUserFile /home/B/etc/dav.digest.passwd
Require valid-user
ForceType text/plain
Satisfy All
RemoveHandler .php
RemoveHandler .php5
RewriteEngine off
</Location>
<Files awstats.pl>
AuthName "B.com statistics"
AuthType Basic
AuthUserFile /home/B/.awstats-htpasswd
require valid-user
</Files>
RedirectMatch /cgi-bin/mailman/([^/\.]*)(.cgi)?(.*) https://B.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$3
RedirectMatch /mailman/([^/\.]*)(.cgi)?(.*) https://B.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$3
</VirtualHost>
<VirtualHost 111.222.333.444:80>
SuexecUserGroup "#503" "#503"
ServerName A.com
ServerAlias www.A.com
ServerAlias webmail.A.com
ServerAlias admin.A.com
DocumentRoot /var/www/html/mediashare3
ErrorLog /var/log/virtualmin/A.com_error_log
CustomLog /var/log/virtualmin/A.com_access_log combined
ScriptAlias /cgi-bin/ /home/A/cgi-bin/
ScriptAlias /awstats/ /home/A/cgi-bin/
DirectoryIndex index.html index.htm index.php index.php4 index.php5
<Directory /var/www/html/mediashare3>
Options -Indexes +IncludesNOEXEC +FollowSymLinks +ExecCGI
allow from all
AllowOverride All
AddHandler fcgid-script .php
AddHandler fcgid-script .php5
FCGIWrapper /home/A/fcgi-bin/php5.fcgi .php
FCGIWrapper /home/A/fcgi-bin/php5.fcgi .php5
</Directory>
<Directory /home/A/cgi-bin>
allow from all
</Directory>
RewriteEngine on
RewriteCond %{HTTP_HOST} =webmail.A.com
RewriteRule ^(.*) https://A.com:20000/ [R]
RewriteCond %{HTTP_HOST} =admin.A.com
RewriteRule ^(.*) https://A.com:10000/ [R]
RemoveHandler .php
RemoveHandler .php5
IPCCommTimeout 31
FcgidMaxRequestLen 1073741824
Alias /dav /home/A/public_html
Alias /pipermail /var/lib/mailman/archives/public
<Location /dav>
AV on
AuthType Basic
AuthName "A.com"
AuthUserFile /home/A/etc/dav.digest.passwd
Require valid-user
ForceType text/plain
Satisfy All
RemoveHandler .php
RemoveHandler .php5
RewriteEngine off
</Location>
<Files awstats.pl>
AuthName "A.com statistics"
AuthType Basic
AuthUserFile /home/A/.awstats-htpasswd
require valid-user
</Files>
RedirectMatch /cgi-bin/mailman/([^/\.]*)(.cgi)?(.*) https://A.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$3
RedirectMatch /mailman/([^/\.]*)(.cgi)?(.*) https://A.com:10000/virtualmin-mailman/unauthenticated/$1.cgi$3
</VirtualHost>

My named.conf file:

/etc/named.conf

zone "A.com" {
type master;
file "/var/named/A.com.hosts";
allow-transfer {
    127.0.0.1;
    localnets;
    };
};

zone "B.com" {
type master;
file "/var/named/B.com.hosts";
allow-transfer {
    127.0.0.1;
    localnets;
    };
};

Lastly my hosts files:

/var/named/A.com.hosts
$ttl 38400
@   IN  SOA A.com. root.A.com. (
        1343021517
        10800
        3600
        604800
        38400 )
@   IN  NS  A.com.
A.com.  IN  A   111.222.333.444
www.A.com.  IN  A   111.222.333.444
ftp.A.com.  IN  A   111.222.333.444
m.A.com.    IN  A   111.222.333.444
localhost.A.com.    IN  A   127.0.0.1
webmail.A.com.  IN  A   111.222.333.444
admin.A.com.    IN  A   111.222.333.444
mail.A.com. IN  A   111.222.333.444
A.com.  IN  MX  5 mail.A.com.
A.com.  IN  TXT "v=spf1 a mx a:A.com ip4:111.222.333.444 ?all"
ns1.A.com.  IN  NS  111.222.333.444
ns2.A.com.  IN  NS  111.222.333.444

/var/named/B.com.hosts
$ttl 38400
@   IN  SOA A.com. root.A.com. (
        1343020044
        10800
        3600
        604800
        38400 )
@   IN  NS  A.com.
B.com.  IN  A   111.222.333.444
www.B.com.  IN  A   111.222.333.444
ftp.B.com.  IN  A   111.222.333.444
m.B.com.    IN  A   111.222.333.444
localhost.B.com.    IN  A   127.0.0.1
webmail.B.com.  IN  A   111.222.333.444
admin.B.com.    IN  A   111.222.333.444
mail.B.com. IN  A   111.222.333.444
B.com.  IN  MX  5 mail.B.com.
B.com.  IN  TXT "v=spf1 a mx a:B.com ip4:111.222.333.444 ?all"
ns1.A.com.  IN  NS  111.222.333.444
ns2.A.com.  IN  NS  111.222.333.444

Both host files share the same Name Server: ns1.A.com & ns2.A.com. Visiting site www.A.com works, visiting www.B.com fails (server not found), but visiting the server IP address (111.222.333.444) brings me to www.B.com (instead of www.A.com?).

Questions:

1) Should www.B.com hosts have its own NS (ex: ns1.B.com., ns2.B.com.)
2) Why does visiting www.B.com fail, when the hosts files are almost identical?
3) How come www.B.com shows when navigating to the server IP when the document root is "/var/www/html", yet www.B.com resides in "/var/www/html/B/index.htm" 

Hopefully these are the right files to be looking at to obtain the answers, or should I be focusing my efforts somewhere else? Thanks for any advice you can shine on the topic.

share|improve this question
    
Please share apache config. The virtual section bit. –  Sameer Jul 25 '12 at 1:47
    
I agree with Sameer. The devil is in the details of the apache config in this case, and not necessarily what it looks like. Please copy and paste it accurately. A typographical error could be the cause. –  Skaperen Jul 25 '12 at 1:57
    
added apache http.conf (virtual section) as per request, it appears virtualmin added a lot of stuff. –  ifft Jul 25 '12 at 1:58
1  
What does whois say the name servers for b.com are? For example, networksolutions.com/whois/index.jsp is able to look up that info. –  becomingwisest Jul 25 '12 at 2:00
    
WHOIS Results for B.com--- Domain servers in listed order: NS1.A.COM, NS2.A.COM –  ifft Jul 25 '12 at 2:06

2 Answers 2

  1. No. However, if you need to (some day) have HTTPS services for A.com and B.com, they need to use separate IP address. This is because the server must provide its signed certificate for the correct host for the SSL negotiation before the underlying HTTP request can send the hostname it is requesting. Wildcard certificates can allow multiple hostnames in the same domain. But these are not issued across domains.

NS records for a domain should match the delegations for everything to work just right. Mismatches can still work, so the fact that it does appear to work does not necessarily mean everything is as it should be.

  1. Silly answer: because "almost" does not count. Serious answer needs the Apache config file.

  2. Most likely because the first section to match the IP happens to be the one for www.B.com. Details in the config file can make things different that what appears at a quick glance. This is why an accurate copy & paste of the Apache config file is essential.

Edit: I see your added Apache config. The first VH section is for B.com, so that is what an IP based request will get. If you want it to get A.com, switch the order. If you want it get neither, add a new dummy entry (no ServerName) as the first one.

Can you provide more details about what "fails" means when you go to www.B.com? Does it timeout? Does it give a 404? Does it give another error? Does it give wrong output?

share|improve this answer
    
Navigating to www.B.com in Chrome: Error 137 (net::ERR_NAME_RESOLUTION_FAILED): Unknown error. FireFox: (Server Not Found) Firefox can't find the server at www.B.com. Whydown.com (says: Trying local caching DNS server... Inaccessible due to DNS subsystem dysfunction (maybe DNS servers responsible for the website are down or misconfigured) –  ifft Jul 25 '12 at 2:30
1  
Verify the DNS delegation is done correctly by your DNS provider with "dig +norec +trace any www.B.com." Also do it with www.A.com to compare. –  Skaperen Jul 25 '12 at 2:39

After many hours of searching, and poking around, I finally find the answer to my questions/problems, to which I will answer below encase others experience the same issues:

1) Should www.B.com hosts have its own NS (ex: ns1.B.com., ns2.B.com.)

No. However, if you need to (some day) have HTTPS services for A.com and B.com, they need to use separate IP address. (Answered By: Skaperen)

2) Why does visiting www.B.com fail, when the hosts files are almost identical?

The "bind-chroot" package was installed which made the BIND service run in the /var/named/chroot environment. Even though though the settings were correct, the wrong named.conf was being used. (Ex: /var/named/A.com.hosts was in /var/named/chroot/var/named/A.com.hosts). Using the YUM command to remove the "bind-chroot" package and restarting BIND in webmin fixed the DNS problem, and now site A.com and B.com both work.

3) How come www.B.com shows when navigating to the server IP when the document root is "/var/www/html", yet www.B.com resides in "/var/www/html/B/index.htm" 

Answer: The first VirtualHost section (IP address) is for B.com (Document Root).

  Ex:
<-VirtualHost 111.222.333.444:80>
DocumentRoot /var/www/html/B
<-/VirtualHost>
(Answered By: Skaperen)

Hopefully these questions/answers can help other new linux users out there in the future.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.