LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Server
User Name
Password
Linux - Server This forum is for the discussion of Linux Software used in a server related context.

Notices


Reply
  Search this Thread
Old 02-23-2009, 07:24 PM   #1
int0x80
Member
 
Registered: Sep 2002
Location: Cincinnati
Distribution: Debian GNU/Linux
Posts: 310

Rep: Reputation: 31
Question [SOLVED] Apache hits wrong VirtualHost without www prefix


Weird problem here that I have not been able to figure out. My server has several vhosts including int0x80.com. On all other vhosts, you land at the correct site regardless of www prefix. However, if you go to http://www.int0x80.com you land in /home/david/www/int0x80.com on the filesystem (right) but if you go to http://int0x80.com you land in /var/www on the filesystem (wrong).

What is really strange is that this has worked fine for years, and then only recently has stopped working properly. AFAICT nothing has been changed on my end config-wise.

apache2ctl configtest ended with Syntax OK

This is from my /etc/apache2/sites-enabled/int0x80:
Code:
NameVirtualHost *:80
NameVirtualHost *:443

<VirtualHost *:80>

ServerName www.int0x80.com
ServerAlias int0x80.com *.int0x80.com
ServerAdmin webadmin@int0x80.com

DocumentRoot /home/david/www/int0x80.com

<Directory />
        Options FollowSymLinks
        AllowOverride AuthConfig
</Directory>

<Directory /home/david/www/int0x80.com>
        Options -Indexes FollowSymLinks MultiViews
        AllowOverride Authconfig
        Order allow,deny
        allow from all
</Directory>

ErrorLog /var/log/apache2/int0x80_error.log
LogLevel warn
LogFormat "%h %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-agent}i\"" combined
CustomLog /var/log/apache2/int0x80_access.log combined
ServerSignature On

</VirtualHost>
This is from /etc/bind/db.int0x80:
Code:
;
; BIND data file for local loopback interface
;
$TTL    604800
@       IN      SOA     www. root.www. (
                              6         ; Serial
                         604800         ; Refresh
                          86400         ; Retry
                        2419200         ; Expire
                         604800 )       ; Negative Cache TTL
;
@       IN      NS      ns4
@       IN      NS      ns2
@       IN      NS      ns1
@       IN      NS      216.68.106.59
@       MX      10      mail
@       IN      A       216.54.147.14
www     IN      A       216.54.147.14
mail    IN      A       216.54.147.14
ns4     IN      A       216.54.147.14
ns2     IN      A       216.54.147.14
ns1     IN      A       216.54.147.14
ns0     IN  CNAME www
agilemc IN      CNAME   www
Any ideas?

Last edited by int0x80; 03-25-2009 at 10:12 AM. Reason: SOLVED
 
Old 02-24-2009, 02:15 AM   #2
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 12,691

Rep: Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823Reputation: 1823
Check if there is a .htaccess in DocumentRoot (/home/david/www/int0x80.com) that rewrites it to /var/www.
This is the only one that comes in mind
 
Old 02-24-2009, 05:08 AM   #3
chitambira
Member
 
Registered: Oct 2008
Location: Fife
Distribution: RHEL, Centos
Posts: 373
Blog Entries: 1

Rep: Reputation: 51
Quote:
<Directory />
Options FollowSymLinks
AllowOverride AuthConfig
</Directory>
have you recently upgraded your apache? Seems like a file match is found in the above directory with corresponding directives. Check well the directives given here, or rather use a single directory section.
Note:If multiple directory sections match the directory (or its parents) containing a document, then the directives are applied in the order of shortest match first, interspersed with the directives from the .htaccess files
 
Old 02-24-2009, 07:56 AM   #4
int0x80
Member
 
Registered: Sep 2002
Location: Cincinnati
Distribution: Debian GNU/Linux
Posts: 310

Original Poster
Rep: Reputation: 31
Unhappy

bathory: No .htaccess files are present in /home/david/www/int0x80.com

chitambira: Unfortunately I don't recall the proximity of any Apache upgrades in relation to when this behavior started. The config structure is identical to the other vhosts on the system, and none of them suffer this behavior. Also I tried commenting out one section at a time and reloading/restarting only to find that the symptoms unfortunately persist.


FYI: Here are log entries from requests for http://int0x80.com and http://www.int0x80.com

Request: http://int0x80.com
Log file: /var/log/apache2/access.log
Code:
216.54.147.14 - - [24/Feb/2009:08:53:50 -0500] "GET / HTTP/1.1" 200 56 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.6) Gecko/2009020911 Ubuntu/8.04 (hardy) Firefox/3.0.6"
Request: http://int0x80.com
Log file: /var/log/apache2/int0x80_access.log
Code:
(No log entry)
Request: http://www.int0x80.com
Log file: /var/log/apache2/access.log
Code:
(No log entry)
Request: http://www.int0x80.com
Log file: /var/log/apache2/int0x80_access.log
Code:
216.54.147.14 - - [24/Feb/2009:08:54:39 -0500] "GET / HTTP/1.1" 200 34 "-" "Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.9.0.6) Gecko/2009020911 Ubuntu/8.04 (hardy) Firefox/3.0.6"
 
Old 02-24-2009, 02:00 PM   #5
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 166Reputation: 166
Quote:
Originally Posted by int0x80 View Post
This is from my /etc/apache2/sites-enabled/int0x80:
Code:
ServerName www.int0x80.com
ServerAlias int0x80.com *.int0x80.com
Try this:

Code:
ServerName int0x80.com
ServerAlias *.int0x80.com
Make sure you stop and start apache after making any config changes.

Last edited by rweaver; 02-24-2009 at 02:10 PM.
 
Old 02-24-2009, 02:47 PM   #6
int0x80
Member
 
Registered: Sep 2002
Location: Cincinnati
Distribution: Debian GNU/Linux
Posts: 310

Original Poster
Rep: Reputation: 31
Unhappy

No go, still the same behavior. Thanks for the suggestion, though.

I always do /etc/init.d/apache2 restart after changes, even though I think in most cases only reload is required (could be wrong).
 
Old 02-24-2009, 04:07 PM   #7
rweaver
Senior Member
 
Registered: Dec 2008
Location: Louisville, OH
Distribution: Debian, CentOS, Slackware, RHEL, Gentoo
Posts: 1,833

Rep: Reputation: 166Reputation: 166
Quote:
Originally Posted by int0x80 View Post
No go, still the same behavior. Thanks for the suggestion, though.

I always do /etc/init.d/apache2 restart after changes, even though I think in most cases only reload is required (could be wrong).
Usually reload is enough, but I think it's generally safer to do a restart if you want to ensure everything is correct.

The other thing that comes to mind is how is your https setup? Is it possible that https is going to /var/www?
 
Old 03-25-2009, 10:14 AM   #8
int0x80
Member
 
Registered: Sep 2002
Location: Cincinnati
Distribution: Debian GNU/Linux
Posts: 310

Original Poster
Rep: Reputation: 31
I found the problem. Under /etc/apache2/sites-enabled, there was a symlink pointing back to /etc/apache2/sites-available/default. With the ServerName being www.int0x80.com, the int0x80.com would cause the default site to be hit. Simply removing the symlink got it working again.

Edit: It should be noted that the httpd was restarted after the symlink was removed.

Last edited by int0x80; 03-25-2009 at 05:33 PM.
 
Old 03-25-2009, 03:37 PM   #9
Lowell1947
Member
 
Registered: May 2007
Location: Florida
Distribution: Ubuntu, SuSE10.2, LFS, Ubuntu Server (AMD64), Windows 7, Mac OSX
Posts: 30

Rep: Reputation: 16
I came on this post a little late. I had the same problem last year and the problem was a smylink. Thanks for posting your solution.
 
Old 04-17-2009, 11:27 AM   #10
chitambira
Member
 
Registered: Oct 2008
Location: Fife
Distribution: RHEL, Centos
Posts: 373
Blog Entries: 1

Rep: Reputation: 51
my earlier contribution, if you had looked at it carefully, should have pointed you to the symlink earlier enough.
 
0 members found this post helpful.
Old 08-26-2010, 05:48 PM   #11
sneakyimp
Senior Member
 
Registered: Dec 2004
Posts: 1,056

Rep: Reputation: 78
Sorry to resurrect an ancient thread, but why does the symlink for the default conf file cause a problem? The default conf doesn't refer to the domain at all so wouldn't the more specific virtual host be used?
 
  


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
VirtualHost directing to the wrong directory. SeaborneClink Linux - Server 5 02-17-2009 03:11 AM
Forbidden with VirtualHost folder other than /var/www/html netweblogic Linux - Server 3 08-28-2008 07:46 AM
Apache VirtualHost - http://www. problem gooddesi Linux - Server 5 04-29-2007 09:57 PM
www prefix prob Roosta21 Linux - Server 3 01-10-2007 12:47 AM
Webserver without www prefix da_tibmeister Linux - Networking 2 08-08-2004 09:07 AM

LinuxQuestions.org > Forums > Linux Forums > Linux - Server

All times are GMT -5. The time now is 11:15 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration