Solved

Apache on Ubuntu

Posted on 2014-01-14
14
173 Views
Last Modified: 2014-01-16
I have inherited an Ubuntu 12.4 server that is hosting a number of web sites.  The nameserver that was running the DNS management has been shut down and I need to access the web sites so we can copy them to another location.

I can access the command line on the Ubuntu server and can see the .conf files for the sites but cannot access them.  

If I navigate to the ip address of the server I can see one of the web sites but can't access the others.

Is there some way I can find a url so I can access these.
0
Comment
Question by:adding7
  • 5
  • 4
  • 3
  • +1
14 Comments
 
LVL 12

Expert Comment

by:junipllc
ID: 39779542
Yes, what kind of computer do you have? You can put the IP address and hostname into your "hosts" file to trick the local machine into sending all of your requests to the IP address with the proper Host: header.

For example, on the Mac you would edit your /etc/hosts file and add:

12.34.56.78   domain.com
12.34.56.78   domain2.com
etc.

where '12.34.56.78' is the IP address and you're basically overriding the actual DNS.

I typically don't like to just put a link up for an answer, but this has all you need in order to accomplish that:

http://www.rackspace.com/knowledge_center/article/how-do-i-modify-my-hosts-file

Cheers,

Mike
0
 
LVL 58

Expert Comment

by:Gary
ID: 39779580
Is this through SSH?
Are you logged in as an admin user? Can you use sudo to open to the file
sudo vi file.conf
0
 
LVL 16

Expert Comment

by:gurutc
ID: 39779608
Also, the IP addresses for the specific websites should be in the conf files for the virtual hosts.  

- gurutc
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

Author Comment

by:adding7
ID: 39779612
Mike,

That's really smart - so I'm not sure why its not working......  I've tried the domain with and without the 'www' in the hosts file.  I've flushed the DNS and can confirm that a 'ping' returns the IP address that I've put in the host file.

When I open a browser, it returns to 'names.co.uk which is where the domain is now hosted!

Sorry, but any ideas?
0
 
LVL 16

Expert Comment

by:gurutc
ID: 39779634
It looks like the sites were sharing the same IP address and were being distinguished by the host header.  So you also need to add host records to your hosts file like so:


12.34.56.78   domain.com
12.34.56.78   domain2.com

12.34.56.78   www.domain.com
12.34.56.78   www.domain2.com

Good Luck,
gurutc
0
 
LVL 58

Expert Comment

by:Gary
ID: 39779642
Is this question how to move files or how to setup virtual domains.
What is the point of modifying your own hosts file? If the DNS is not working then your domain/s in essence do not exist and you can only access the default domain on the server via the IP of the server (which you have found out to be names.co.uk).
So forget all this rubbish about modifying your hosts file.
0
 
LVL 58

Expert Comment

by:Gary
ID: 39779650
It sounds like you need to set up new nameservers somewhere else, who is responsible for your domain registration?  Is the same company that was hosting your nameservers?
0
 
LVL 16

Expert Comment

by:gurutc
ID: 39779656
sorry, I see you've done the hosts thing.

Are you sure your server was only listening on one address?

You can also make your server believe the domains exist by editing the server's host file as well.  That will make them 'exist'

You could try this to make sure the server is listening on only one IP:

netstat  -tanpu | grep ":80 "

- gurutc
0
 
LVL 58

Expert Comment

by:Gary
ID: 39779853
Hello!
The nameserver that was running the DNS management has been shut down

As far as the world is concerned the domains no longer exist!
0
 
LVL 12

Expert Comment

by:junipllc
ID: 39780352
cathal said:

So forget all this rubbish about modifying your hosts file.

I'm sorry, but you are incorrect. Apache will respond to the Host: header regardless of whether the DNS exists publicly. This is the oldest trick in the Web developer's book.

Cheers,

Mike
0
 
LVL 12

Accepted Solution

by:
junipllc earned 500 total points
ID: 39780369
adding7,

I'm not sure why it's not working either. If you can ping the proper IP address, and you are using the domain in your browser, then the browser should send the Host: header to Apache, which via name-based virtual hosting and the magic of HTTP 1.1 will return the proper site.

Open up a command shell and type:

telnet 12.34.56.78 80

where the IP address is the IP of the server. This connects you to port 80 on the machine. You are now acting as a browser would.

Type:

GET / HTTP/1.1
Host: domain.com

(hit enter twice after the domain.com, which of course is your domain). The server should return the response headers as well as the HTML of the front page of the site on domain.com.

See if that works. That will rule out Apache as being the issue. Or it will point the finger squarely at Apache. :)

Cheers,

Mike
0
 
LVL 58

Expert Comment

by:Gary
ID: 39780453
Who cares if you can send an header and get to the website through a browser.  What has that got to do with his DNS problems or getting access to the server
0
 
LVL 12

Expert Comment

by:junipllc
ID: 39780475
@cathal,

That's what he's trying to do. Re-read his question. He said "and I need to access the web sites." and "If I navigate to the ip address of the server I can see one of the web sites but can't access the others." That leads me to believe that he wants access to the sites via a browser. He already has SSH access. Perhaps I am wrong, but that is how I read the question.

The /etc/hosts file will allow him to circumvent DNS altogether. No DNS lookups are ever made, so the fact that there is no public DNS for the sites is irrelevant.
0
 

Author Comment

by:adding7
ID: 39786565
Mike,

I can confirm that you did understand the question absolutely correctly, I am trying to get to a web site that is on the old server so I can copy it to a new location.

Although I haven't managed to do this I suspect - as you suggest - there is a problem with the apache.....

Anyway, your advice was sensible and clear so I have awarded the points accordingly - many thanks.
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Set up notificataion or alert from a website 2 68
AWS Advice on using WHM/cPanel 1 76
Live mode in DW, need to creae Session 4 94
http to https 3 62
Introduction This article explores the design of a cache system that can improve the performance of a web site or web application.  The assumption is that the web site has many more “read” operations than “write” operations (this is commonly the ca…
Meet the world's only “Transparent Cloud™” from Superb Internet Corporation. Now, you can experience firsthand a cloud platform that consistently outperforms Amazon Web Services (AWS), IBM’s Softlayer, and Microsoft’s Azure when it comes to CPU and …
Use Wufoo, an online form creation tool, to make powerful forms. Learn how to choose which pages of your form are visible to your users based on their inputs. The page rules feature provides you with an opportunity to create if:then statements for y…
Learn how to set-up PayPal payment integration in your Wufoo form. Allow your users to remit payment through PayPal upon completion of your online form. This is helpful for collecting membership payments, customer payments, donations, and more.

777 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question