LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Server (http://www.linuxquestions.org/questions/linux-server-73/)
-   -   Apache Virtual Host Issue (http://www.linuxquestions.org/questions/linux-server-73/apache-virtual-host-issue-4175442572/)

psoheil 12-22-2012 11:27 AM

Apache Virtual Host Issue
 
Hello All,

I have a small dedicated server at home which runs Apache/2.2.22 on Fedora Linux 16 with Webmin. I have setup 3 Virtual Hosts using Webmin, which produces the following configuration in /etc/httpd/conf/httpd.conf

Code:

<VirtualHost *:80>
DocumentRoot /home/domain1.sytes.net/www/
ServerName domain1.sytes.net
<Directory "/home/domain1.sytes.net/www/">
allow from all
Options +Indexes
</Directory>
ServerAlias www.domain1.sytes.net
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /home/domain2.sytes.net/www/
ServerName domain2.sytes.net
<Directory "/home/domain2.sytes.net/www/">
allow from all
Options +Indexes
</Directory>
ServerAlias www.domain2.sytes.net
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /home/domain3.sytes.net/www/
ServerName domain3.sytes.net
<Directory "/home/domain3.sytes.net/www/">
allow from all
Options +Indexes
</Directory>
ServerAlias www.domain3.sytes.net
</VirtualHost>

For some reason the first 2 virtual hosts are working fine, but the third one I just added is not working and redirects traffic to the default apache server page. Does anyone have any suggestions as to why the 3rd host may not be working? The settings are identical to one another and I restarted apache several times without any luck.

Thanks,
Pete

bathory 12-22-2012 01:12 PM

Hi,

What is the output of:
Code:

apachectl -S

psoheil 12-22-2012 01:35 PM

Here is the response to that command:

Quote:

httpd: Could not reliably determine the server's fully qualified domain name, using fe80::213:72ff:fe0d:2760 for ServerName
[Sat Dec 22 13:26:55 2012] [warn] NameVirtualHost XXX.YYY.ZZZ.KKK:0 has no VirtualHosts
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server domain1.sytes.net (/etc/httpd/conf/httpd.conf:1009)
port 80 namevhost domain1.sytes.net (/etc/httpd/conf/httpd.conf:1009)
port 80 namevhost domain2.sytes.net (/etc/httpd/conf/httpd.conf:1018)
port 80 namevhost domain3.sytes.net (/etc/httpd/conf/httpd.conf:1027)
Syntax OK
I am using NO-IP.com Dynamic DNS Service to point to my home Server. The first two do resolve fine with the existing configuration, just not domain3.sytes.net.

Pete

bathory 12-22-2012 03:47 PM

From the output looks like your vhosts are ok.
Quote:

I am using NO-IP.com Dynamic DNS Service to point to my home Server. The first two do resolve fine with the existing configuration, just not domain3.sytes.net.
I don't know how NO-IP can assign the same dynamic IP to more than one hostnames, but maybe you have a typo in NO-IP configuration, so your IP does not actually resolve to domain3.sytes.net

psoheil 12-22-2012 06:06 PM

I double checked the host name, and verified that domain3.sytes.net does resolve to the correct IP and makes it as far as my server. So the problem must be on my server! I just don't see it somehow. :(

Pete

John VV 12-23-2012 01:29 AM

no-ip is good

a wilde guess is that your issue is on that side
recheck your no-ip.com set up

now on the other hand with all three on port 80 ?????
that could cause some " fun"

putting the third on 8080 might do it

bathory 12-23-2012 02:21 AM

Quote:

Originally Posted by psoheil (Post 4855195)
I double checked the host name, and verified that domain3.sytes.net does resolve to the correct IP and makes it as far as my server. So the problem must be on my server! I just don't see it somehow. :(

Pete

If the hostname resolves to your IP and apache has a vhost with that ServerName, then you should see that instead of the default. That's why we think there is a discrepancy between the No-IP hostname and the vhost ServerName.

BTW to get rid of:
Quote:

[Sat Dec 22 13:26:55 2012] [warn] NameVirtualHost XXX.YYY.ZZZ.KKK:0 has no VirtualHosts
search httpd.conf (and perhaps the included apache config files) for a second "NameVirtualHost .." definition and delete it. According to your vhosts configuration there should be only a "NameVirtualHost *:80" directive.

psoheil 12-23-2012 10:11 AM

Quote:

Originally Posted by bathory (Post 4855322)
If the hostname resolves to your IP and apache has a vhost with that ServerName, then you should see that instead of the default. That's why we think there is a discrepancy between the No-IP hostname and the vhost ServerName.

I tipple checked the no-ip setting and it is resolving to my server fine. There really isn't a whole lot of settings on the no-ip end, and I re-checked the few there is and confirmed there is no difference between the settings of the 3 sub domains. I also re-checked and made sure there is no difference between the way the sub domains are entered into no-ip and the way I have them in my configuration file. I even double checked the file system permission of the folder where domain3 is pointing and it has the identical file system permission as the others. It makes no sense! I am open to any other suggestions anyone may have in this regard. :(

Quote:

Originally Posted by bathory (Post 4855322)
BTW to get rid of:
search httpd.conf (and perhaps the included apache config files) for a second "NameVirtualHost .." definition and delete it. According to your vhosts configuration there should be only a "NameVirtualHost *:80" directive.

I did find a second IP Specific NameVirtualHost entry and commented it out, which got rid of the warning:

Quote:

httpd: Could not reliably determine the server's fully qualified domain name, using fe80::213:72ff:fe0d:2760 for ServerName
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server domain1.sytes.net (/etc/httpd/conf/httpd.conf:1009)
port 80 namevhost domain1.sytes.net (/etc/httpd/conf/httpd.conf:1009)
port 80 namevhost domain2.sytes.net (/etc/httpd/conf/httpd.conf:1018)
port 80 namevhost domain3.sytes.net (/etc/httpd/conf/httpd.conf:1027)
Syntax OK
I also don't see any relevant error messages in the error_log or access_log.

By the way, the Default Server has the following configuration:

Address: Any
Port: Any
Server Name: Automatic
Document Root: /var/www/html

Would that effect the settings for domain3 in any way?

Thanks,
Pete

tquang 12-23-2012 11:28 AM

Re-check port listen in httpd.conf
Code:

Listen 80
Add above and restart it
Code:

NameVirtualHost *:80
In Apache 2.4 directive NameVirtualHost no need because Apache's development had removed it.

Code:

NameVirtualHost *:80
<VirtualHost *:80>
DocumentRoot /home/domain1.sytes.net/www/
ServerName domain1.sytes.net
<Directory "/home/domain1.sytes.net/www/">
allow from all
Options +Indexes
</Directory>
ServerAlias www.domain1.sytes.net
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /home/domain2.sytes.net/www/
ServerName domain2.sytes.net
<Directory "/home/domain2.sytes.net/www/">
allow from all
Options +Indexes
</Directory>
ServerAlias www.domain2.sytes.net
</VirtualHost>

<VirtualHost *:80>
DocumentRoot /home/domain3.sytes.net/www/
ServerName domain3.sytes.net
<Directory "/home/domain3.sytes.net/www/">
allow from all
Options +Indexes
</Directory>
ServerAlias www.domain3.sytes.net
</VirtualHost>


bathory 12-23-2012 12:29 PM

Quote:

By the way, the Default Server has the following configuration:

Address: Any
Port: Any
Server Name: Automatic
Document Root: /var/www/html

Would that effect the settings for domain3 in any way?
Dunno how webmin works, but since the other 2 vhost work, it shouldn't matter.
What happens if you manually move the 3rd vhost stanza before the 1st one in httpd.conf, so it becomes the default vhost?

psoheil 12-23-2012 02:44 PM

1 Attachment(s)
Quote:

Originally Posted by tquang (Post 4855554)
Re-check port listen in httpd.conf
Code:

Listen 80
Add above and restart it
Code:

NameVirtualHost *:80
In Apache 2.4 directive NameVirtualHost no need because Apache's development had removed it.

I already had "Listen 80" in my config file, and removing NameVirtualHost directive not only didn't help but it broke the other two domains, and generated the following two errors on restart of apache:

Code:

[Sun Dec 23 14:23:52 2012] [warn] _default_ VirtualHost overlap on port 80, the first has precedence
[Sun Dec 23 14:23:52 2012] [warn] _default_ VirtualHost overlap on port 80, the first has precedence

As far as the other suggestion:

Quote:

Originally Posted by bathory (Post 4855588)
Dunno how webmin works, but since the other 2 vhost work, it shouldn't matter.
What happens if you manually move the 3rd vhost stanza before the 1st one in httpd.conf, so it becomes the default vhost?

I moved the 3rd vhost up to the beginning and restarted apache, but it made no difference.

I am posting my complete httpd.conf file here as an attachment in hope that someone can point out what the actual problem may be.

Attachment 11458

Thanks,
Pete

bathory 12-24-2012 02:43 AM

I'm baffled. Your config looks ok, so I cannot tell what the problem really is.
I still suspect some typo in the vhost definition, as the hostname resolves correctly to your apache IP, but apache does not know that vhost name, so it gives the default server.
Have you tried to use both domain3.sytes.net and www.domain3.sytes.net?
Also try to use telnet and see what you get:
Code:

telnet x.x.x.x 80
GET / HTTP/1.1
host: domain3.sytes.net
<Enter>
<Emter>


psoheil 12-24-2012 07:24 AM

Quote:

Originally Posted by bathory (Post 4855944)
I'm baffled. Your config looks ok, so I cannot tell what the problem really is.
I still suspect some typo in the vhost definition, as the hostname resolves correctly to your apache IP, but apache does not know that vhost name, so it gives the default server.
Have you tried to use both domain3.sytes.net and www.domain3.sytes.net?
Also try to use telnet and see what you get:
Code:

telnet x.x.x.x 80
GET / HTTP/1.1
host: domain3.sytes.net
<Enter>
<Emter>


The www.domain3.sytes.net doesn't resolve at all (brings up a blank page). Only domain3.sytes.net goes to the test page of apache.

I tried and telnet to the server from another machine and still got the html of the apache test page. :(

Pete

bathory 12-24-2012 08:39 AM

Quote:

The www.domain3.sytes.net doesn't resolve at all (brings up a blank page)
That means it resolves to some ip, otherwise you should get an error. Use
Code:

nslookup www.domain3.sytes.net
to see where it resolves.


Quote:

Only domain3.sytes.net goes to the test page of apache.
What happens if you replace the default "/var/www/html" in DocumentRoot with "/home/domain3.sytes.net/www"?

psoheil 12-24-2012 01:12 PM

Quote:

Originally Posted by bathory (Post 4856079)
That means it resolves to some ip, otherwise you should get an error. Use
Code:

nslookup www.domain3.sytes.net
to see where it resolves.

Here is what I get for "www.domain3.sytes.net":

Quote:

Server: XXXXX.comcast.net
Address: XX.XX.XX.XX (not my IP)

*** XXXXX.comcast.net can't find www.domain3.sytes.net: Non-existent domain
I get this response for both my other domains too though, so I don't think that's the problem.

Quote:

Originally Posted by bathory (Post 4856079)
What happens if you replace the default "/home" in DocumentRoot with "/home/domain3.sytes.net/www"?

I still get the apache test page for domain3. I even tried adding a 4th domain "domain4.no-ip.info" and the 4th domain shows the same apache test page, even though everything is correct! I have to admit this is one of the strangest problems I have had in my 20 years of work!

Pete


All times are GMT -5. The time now is 09:52 PM.