Linode Forum
Linode Community Forums
 FAQFAQ    SearchSearch    MembersMembers      Register Register 
 LoginLogin [ Anonymous ] 
Post new topic  Reply to topic
Author Message
PostPosted: Sun Oct 21, 2012 4:38 pm 
Offline
Senior Newbie

Joined: Sun Oct 21, 2012 3:58 pm
Posts: 6
I have 1 site running fine on my server, and have added a second as virtualhost.

if i put an entry for it in my hosts file on the server, i can curl it on the server. If i do the same on my remote machine though i don't get any response.

Apache appears to be running the 2 sites fine:

VirtualHost configuration:
wildcard NameVirtualHosts and _default_ servers:
*:80 is a NameVirtualHost
default server www.devhaus.co.uk (/etc/apache2/sites-enabled/devhaus.co.uk:4)
port 80 namevhost www.devhaus.co.uk (/etc/apache2/sites-enabled/devhaus.co.uk:4)
port 80 namevhost www.shape-shift-test.co.uk (/etc/apache2/sites-enabled/shape-shift-test.co.uk:4)
Syntax OK

Its the shape-shift site i'm trying to get working. Devhaus is a proper domain but shape-shift-test is one i've made up.

Any ideas?

Thanks


Top
   
PostPosted: Sun Oct 21, 2012 6:37 pm 
Offline
Senior Member
User avatar

Joined: Sat Aug 30, 2008 1:55 pm
Posts: 1739
Location: Rochester, New York
shape-shift-test.co.uk is not known by the co.uk zone, so indeed, it doesn't exist. You'll have to contact the co.uk folks and probably give them some money to make it work.

_________________
Code:
/* TODO: need to add signature to posts */


Top
   
PostPosted: Mon Oct 22, 2012 3:41 am 
Offline
Senior Newbie

Joined: Sun Oct 21, 2012 3:58 pm
Posts: 6
Ah right, so it has to be a valid, registered domain even when testing and using /etc/hosts?

Thanks


Top
   
PostPosted: Mon Oct 22, 2012 3:46 am 
Offline
Senior Member

Joined: Sun Apr 26, 2009 3:37 am
Posts: 72
Website: http://wiggenhorn.org/
Add the domain to /etc/hosts on the remote machine, too.


Top
   
PostPosted: Mon Oct 22, 2012 8:22 am 
Offline
Senior Newbie

Joined: Sun Oct 21, 2012 3:58 pm
Posts: 6
I do have the entry in my remote machine's host file, exactly the same as the test on the server. But, on the server from a command prompt, it responds to both ping and curl. From the remote machine, with the same entry in it's hosts file, neither ping nor curl get a response.

Both ping and curl work from the remote machine to the devhaus.co.uk domain.

Thanks


Top
   
PostPosted: Mon Oct 22, 2012 8:46 am 
Offline
Senior Newbie

Joined: Thu Jan 19, 2012 10:12 am
Posts: 6
Apache is running the site fine.
The way apache virtual hosts work is to look at the "host" header in the http request to work out which virtual host to route the request to. When you use a web browser to access virtual.site.com, your computer does a DNS lookup on virtual.site.com to find the IP address associated with that DNS record, and then sends the request to that IP address with the http host header set to "virtual.site.com", which lets the servers know that it should serve the site virtual.site.com, even if there are multiple sites on that IP address. If the host header isn't set, or if apache doesn't have a virtual site for that host, it serves the default site. In your case, this is http://www.devhaus.co.uk.
If I make a request to 176.58.108.244 (your IP address) and modify the host header to be "www.shape-shift-test.co.uk" I get served the site as expected (at the moment all the site consists of is a 500 error saying it couldn't connect to the database).
I'm unsure as to why /etc/hosts isn't working as you want, however I have experienced /etc/hosts causing a lot of issues with apache, so maybe that'd explain it. It may also be useful to see a dump of your /etc/hosts file.
If you want to modify your headers yourself, so as to access the site remotely, you can use a tool such as https://addons.mozilla.org/en-US/firefo ... y-headers/ (I expect chrome also has similar addons).
You can also do something similar with curl. I believe the usage is something along the lines of:
Code:
curl -H 'Host: www.shape-shift-test.co.uk' http://176.58.108.244/


Top
   
PostPosted: Mon Oct 22, 2012 10:18 am 
Offline
Senior Newbie

Joined: Sun Oct 21, 2012 3:58 pm
Posts: 6
That's really interesting, thanks. For some reason if i add the entry in my hosts on windows, on my work machine, it works. So, something odd going on with my mac maybe.

Weird.

Thanks for you help everyone anyway


Top
   
PostPosted: Mon Oct 22, 2012 11:40 am 
Offline
Senior Newbie

Joined: Thu Jan 19, 2012 10:12 am
Posts: 6
No worries. Wouldn't surprise me if it was just mac treating the hosts file a bit strangely. To be honest a lot of systems/applications have their little quirks with regard to that file.
Give a shout if you have any further questions. :)


Top
   
PostPosted: Mon Oct 22, 2012 3:30 pm 
Offline
Senior Newbie

Joined: Sun Oct 21, 2012 3:58 pm
Posts: 6
Well, I cannot explain the problem with my hosts file. I deleted every line in it one by one, until only my line was left. Still didnt work. So, I removed the hosts file, and created it new with exactly the same line in and works!

So odd.

I'd even checked the file perms and owner, and all were the same.

It remains a mystery :)


Top
   
PostPosted: Mon Oct 22, 2012 4:53 pm 
Offline
Senior Member
User avatar

Joined: Sun Dec 27, 2009 11:12 pm
Posts: 1038
Location: Colorado, USA
Did you remember to flush the DNS Cache after changing the records?

_________________
Either provide enough details for people to help, or sit back and listen to the crickets chirp.
Security thru obscurity is a myth - and really really annoying.


Top
   
PostPosted: Sat Oct 27, 2012 11:50 am 
Offline
Senior Newbie

Joined: Sun Oct 21, 2012 3:58 pm
Posts: 6
I was flushing the cache each time with dscacheutil -flushcache


Top
   
Display posts from previous:  Sort by  
Post new topic  Reply to topic


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  
RSS

Powered by phpBB® Forum Software © phpBB Group