LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
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 08-30-2013, 12:03 PM   #1
rogerdv
Member
 
Registered: Jul 2005
Location: Cuba
Distribution: redhat
Posts: 52

Rep: Reputation: 15
problem with name based virtual hosts and fre .tk domains


I need to host 2 sites in a VPS, each of them has its own domain name registered via dot tk. I thought that configuring a name virtual host was trivial, but it doesnt works, the first site is displayed for both names. This is the conf:

Code:
# All virtual hosts
<VirtualHost domain1.tk>
       ServerName www.domain1.tk
       DocumentRoot /var/www/html/1.tk
       <Directory /var/www/html/1.tk>
               AllowOverride all
               Options -MultiViews
       </Directory>
</VirtualHost>


<VirtualHost domain2.tk>
       ServerName domain2.tk
       DocumentRoot /var/www/html/2.tk
       <Directory /var/www/html/2.tk>
               AllowOverride all
               Options -MultiViews
       </Directory>
</VirtualHost>
Also, I have noticed something, even if I stop apache, the site still can be accessed! The server runs Centos 6.4 and it is hosted on a Linode VPS.
 
Old 08-30-2013, 12:07 PM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
if you have stopped apache, then clearly you aren't hosting the site yourself or you haven't actually stopped in the first place. Are there hits in the access_log file? can you access it from the local host machine using curl? Bypass all the public IP stuff by running
Code:
curl -v 127.0.0.1 -H "Host: domain1.tk"
and see what's happening then. And show us if things don't clarify themselves.
 
Old 08-30-2013, 12:28 PM   #3
rogerdv
Member
 
Registered: Jul 2005
Location: Cuba
Distribution: redhat
Posts: 52

Original Poster
Rep: Reputation: 15
Ok, I have found the cause of the misterious ghost page, seems that Firefox is loading from cache even when I explicitly ask to refresh the page several times. But still have the virtual host problem, both names redirect to same site.
 
Old 08-30-2013, 12:35 PM   #4
rosehosting.com
Member
 
Registered: Jun 2012
Location: Missouri, USA
Posts: 236

Rep: Reputation: 64
You need to turn on name-based host resolution. Edit your Apache configuration file and add 'NameVirtualHost' as follows:

NameVirtualHost *:80

then, restart your Apache service for the changes to take effect.
 
Old 08-30-2013, 12:44 PM   #5
rogerdv
Member
 
Registered: Jul 2005
Location: Cuba
Distribution: redhat
Posts: 52

Original Poster
Rep: Reputation: 15
Didnt worked. Still only one site is served.
 
Old 08-30-2013, 12:52 PM   #6
rosehosting.com
Member
 
Registered: Jun 2012
Location: Missouri, USA
Posts: 236

Rep: Reputation: 64
You can verify the virtual host configuration syntax using the 'httpd -S' command-line command:

httpd -S
 
Old 09-01-2013, 01:18 PM   #7
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by rogerdv View Post
Didnt worked. Still only one site is served.
If you used
Quote:
NameVirtualHost *:80
then you need to use the same notation for the vhosts:
Code:
<VirtualHost *:80>
       ServerName www.domain1.tk
       DocumentRoot /var/www/html/1.tk
       <Directory /var/www/html/1.tk>
               AllowOverride all
               Options -MultiViews
       </Directory>
</VirtualHost>


<VirtualHost *:80>
       ServerName domain2.tk
       DocumentRoot /var/www/html/2.tk
       <Directory /var/www/html/2.tk>
               AllowOverride all
               Options -MultiViews
       </Directory>
</VirtualHost>
Regards
 
Old 09-02-2013, 07:28 AM   #8
rogerdv
Member
 
Registered: Jul 2005
Location: Cuba
Distribution: redhat
Posts: 52

Original Poster
Rep: Reputation: 15
I have tried all possible combinations and the result is the same.
 
Old 09-02-2013, 09:55 AM   #9
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
Originally Posted by rogerdv View Post
I have tried all possible combinations and the result is the same.
Don't make combinations. Use the same *:80 notation as in my example above for both the NameVirtualhost directive and the VirtualHost containers.Also what is the output of:
Code:
httpd -S
 
Old 09-02-2013, 10:00 AM   #10
rogerdv
Member
 
Registered: Jul 2005
Location: Cuba
Distribution: redhat
Posts: 52

Original Poster
Rep: Reputation: 15
This is httpd -S


Code:
VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
_default_:443          li591-188.members.linode.com (/etc/httpd/conf.d/ssl.conf:74)
*:80                   is a NameVirtualHost
         default server gitlab.lime-engine.tk (/etc/httpd/conf.d/gitlab.conf:10)
         port 80 namevhost gitlab.lime-engine.tk (/etc/httpd/conf.d/gitlab.conf:10)
         port 80 namevhost www.lime-engine.tk (/etc/httpd/conf.d/virtual_hosts.conf:6)
         port 80 namevhost santiagodecuba.tk (/etc/httpd/conf.d/virtual_hosts.conf:18)
Syntax OK
 
Old 09-02-2013, 11:48 AM   #11
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
Quote:
*:80 is a NameVirtualHost
default server gitlab.lime-engine.tk (/etc/httpd/conf.d/gitlab.conf:10)
port 80 namevhost gitlab.lime-engine.tk (/etc/httpd/conf.d/gitlab.conf:10)
port 80 namevhost www.lime-engine.tk (/etc/httpd/conf.d/virtual_hosts.conf:6)
port 80 namevhost santiagodecuba.tk (/etc/httpd/conf.d/virtual_hosts.conf:18)
You have 3 vhosts with gitlab.lime-engine.tk being the default one. Which vhost(s) is the one you can't see?
Also make sure you've cleaned your browser cache before testing
 
Old 09-02-2013, 11:51 AM   #12
rogerdv
Member
 
Registered: Jul 2005
Location: Cuba
Distribution: redhat
Posts: 52

Original Poster
Rep: Reputation: 15
santiagodecuba.tk shows www.lime-engine.tk. Tested our gitlab domain and it shows an empty page, but I dont know if my friend finished installation of gitlab or not. And yes, I have cleaned cache.
 
Old 09-02-2013, 12:00 PM   #13
rogerdv
Member
 
Registered: Jul 2005
Location: Cuba
Distribution: redhat
Posts: 52

Original Poster
Rep: Reputation: 15
I took the precaution of moving to naother PC and cleaning cache several times. Then fixed conf to follow this notation:

Quote:
Originally Posted by bathory View Post
Code:
<VirtualHost *:80>
       ServerName www.domain1.tk
       DocumentRoot /var/www/html/1.tk
       <Directory /var/www/html/1.tk>
               AllowOverride all
               Options -MultiViews
       </Directory>
</VirtualHost>


<VirtualHost *:80>
       ServerName domain2.tk
       DocumentRoot /var/www/html/2.tk
       <Directory /var/www/html/2.tk>
               AllowOverride all
               Options -MultiViews
       </Directory>
</VirtualHost>
Regards
And I get this for both domains:
500
We're sorry, but something went wrong.
 
Old 09-02-2013, 01:27 PM   #14
bathory
LQ Guru
 
Registered: Jun 2004
Location: Piraeus
Distribution: Slackware
Posts: 13,163
Blog Entries: 1

Rep: Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032Reputation: 2032
If you get a 500 "Internal Server Error", you should look in apache error_log to find the reason.
 
Old 09-03-2013, 09:16 AM   #15
dinakumar12
Member
 
Registered: Mar 2010
Location: INDIA (chennai)
Distribution: centos
Posts: 271
Blog Entries: 7

Rep: Reputation: 18
Can you please edit you conf as below,restart apache and try after clearing cache.

NameVirtualHost *:80

<VirtualHost *:80>
ServerName www.domain1.tk
DocumentRoot /var/www/html/1.tk
<Directory /var/www/html/1.tk>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>


<VirtualHost *:80>
ServerName domain2.tk
DocumentRoot /var/www/html/2.tk
<Directory /var/www/html/2.tk>
AllowOverride all
Options -MultiViews
</Directory>
</VirtualHost>
 
  


Reply

Tags
virtual host



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
Problem setting up multiple name based virtual hosts on SiSE 10 baldur2630 Linux - Server 0 10-26-2008 06:07 AM
Apache2 Name-based Virtual Hosts Problem with .org domain! phoenix09 Linux - Software 18 09-19-2006 04:23 AM
Sub Domains & Virtual Hosts oO_SwooP_Oo Linux - General 11 09-21-2005 02:07 PM
Apache - name based virtual hosts? Moses420ca Linux - Software 7 01-26-2005 11:04 AM
IP based virtual hosts problem adm1329 Linux - Networking 4 03-11-2004 10:40 AM

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

All times are GMT -5. The time now is 03:56 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
Open Source Consulting | Domain Registration