Forum Moderators: phranque

Message Too Old, No Replies

Problem with web server on lan

re-maping dns

         

mack

11:47 am on Jun 21, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Hi there.
Probably an easy one for all you networking experts out there, but has got me stumped.

I have a small lan with 2 computers. The gatway computer is running windows xp pro and connects through a dial up. The second computer is linux running apache web server. Is it possible to direct any used why tries to access the lan ip to the localhost of apache. I thought it might have been as simple as altering the host file to...
[lan ip of linux] localhost

I then refreshed the dns, went to localhost and got a 404.

Any ideas.
Thanks in advance.

Mack.

pixel_juice

5:14 pm on Jun 21, 2003 (gmt 0)

10+ Year Member



Hi Mack.

I'm not a 100% sure on this one, but here goes.

The hosts file can be used to force requests for certain hostnames to a specific IP address. So if you has a website running on apache called hostwidget.domainwidget then in the hosts file you would have

[apache ip] hostwidget.domainwidget

However, in order for the site to be returned, the apache server must be accepting requests for hostwidget.domainwidget, otherwise there is no site to return.

So unless you have a site 'localhost' running on apache, it won't know what to return when you request it from the IP. Does this make sense?

Also, you might run into problems redirecting requests for localhost, since it is often used by software for local requests.

As I say, i'm not completely sure :)

mack

5:51 pm on Jun 21, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I think I get what you mean...
On linux if I open a browser and go to [localhost...] I get the index page for Apache, so for this side of thing all appears to be set up ok.

If I go to the windows machine and go to [[linux...] ip] it also shows the apache index page.

What would I put in host file for this?

[linux ip] localhost localhost?

im confused ;-)

Mack.

pixel_juice

6:37 pm on Jun 21, 2003 (gmt 0)

10+ Year Member



>>im confused ;-)

Hmm, me too ;)

I think we need to try and isolate the problem. Try changing the hosts file to point at a website with a host header and domain name on your apache server, if you have one. At least then we'll know if the hosts file on the XP machine is working OK.

If the hosts file does work, maybe it's something to do with the way apache handles 'htpp://localhost'.

mack

8:33 pm on Jun 21, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I dont have any domains set up on the apache.

All I have is /usr/local/httpd/htdocs

this is the area on the server "localhost" that I want to make available.

Im still confused ;-)

Mack.

pixel_juice

11:14 pm on Jun 21, 2003 (gmt 0)

10+ Year Member



I know more about hosts files than apache i'm afraid, so that might be why I can't explain very well. I'll try again, sorry if i'm saying stuff that's obvious and you already know :)

The hosts file basically specifies the IP of a given hostname, so you don't look it up with DNS as normally happens. So if I entered 127.0.0.1 www.webmasterworld.com, I would never lookup the IP of webmasterworld when I went to the site. Instead, my browser would talk to 127.0.0.1 and ask for www.webmasterworld.com. 127.0.0.1 is my local computer. However, since my PC isn't running a server that accepts requests for webmasterworld.com, I will get a 404 page.

So, unless your apache server accepts outside requests for localhost at the IP you specified, then you will see a 404.

However, there are other reasons why it might not be working, for instance a proxy might affect the way the hosts file works.

As I mentioned, I don't know much about apache, so I don't know if the stuff you see when you type in http;//localhost is available to outside PCs. Maybe someone who knows apache could help us out?

mack

11:30 pm on Jun 21, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Thanks pixel_juice.
What I have been trying to do is specify a line in the host file (on xp) so that anything that would normaly go to local host woudl be sent across the lan to the linux server the entry I used was
192.168.0.1 localhost

I just assumed that this would tell the xp machine that anything that accessed it's internet ip and was looking for content would be sent to 192.168.0.1 (the lan ip of linux) Turns out localhost can't be used to access other machine. I made another line
foo 192.168.0.1
Now if I type [foo...] in the address bar I get to view index of apache ;-)

Appears to have worked. The mistake I was making was trying to forward localhost to another localhost... Sill fool that I am.

[added] still cant get access from outside network, tried [[web...] ip]/foo

Any ideas...

Thanks for your great help.

Mack.

mack

3:14 pm on Jun 22, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Still can't get access from outside the lan.

Shoukld I perhaps think about intalling third party routing software or is there something I have overlooked?

Mack.

Stretch

8:43 pm on Jun 22, 2003 (gmt 0)

10+ Year Member



Hi mack

Your hosts file won't route external requests, only requests made by the xp machine itself.

What you need is port forwarding, so any requests sent to port 80 are forwarded to the apache box. If memory serves me correctly, ICS (Internet Connection Sharing) in XP allows port forwarding.

Be warned though, enabling ICS will force the XP box to use the IP 192.168.0.1, so before you do this change the Linux box IP to something else (i.e 192.168.0.2).

I'm using a 2000 box but it should be the same so if you go to the properties of your internet connection there should be a sharing tab. If you enable sharing then choose settings and then the services tab you should be able to add a service using the name 'web' (or whatever), port 80, leave TCP enabled and then enter the IP for you Apache box (192.168.0.2). Re-establish the connection and it should work from outside the LAN.

I don't know of any stand alone routing software that will do this but I'd be surprised if it didn't exist.

If Apache doesn't have a virtual host or domain specified for a request it will respond with the first host specified in the httpd.conf file. I.E, if it gets a request for [example.com,...] but [example.com...] doesn't exist, it will display the page of the first domain it is set up with instead. Likewise, if it receives a request just by IP it will display the default page.

Cheers

Stretch

mack

12:51 am on Jun 23, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



Thanks for that great info Stretch.
I followed your steps and set up ICS to forward everthing on port 80 to the new lan ip of the linux box. Now the only problem I have is I have no way of knowing if it works. because you cant use full addresses from within a network. Is there any way round this.

still confused lol

Thanks again.

Mack.

Stretch

7:41 am on Jun 23, 2003 (gmt 0)

10+ Year Member



The only way to really test it is to try connecting from outside the LAN.

Your best bet would be asking a friend to try and connect at an agreed time when you will be online.

Of course, for this to work, you need to know your IP before calling. Bearing in mind you are probably assigned a dynamic IP (i.e one that changes everytime you connect) this could be tricky to orchestrate.

Perhaps looking at using the services of a company like www.dyndns.com to assign a static name to your dynamic IP would help.

mack

5:19 pm on Jun 23, 2003 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



I used one of the free dynamic ip services, worked a treat.

Thanks for the great help guys.

Mack.