Testing web server on local network with ports... how to use with hosts file?
Linux - ServerThis forum is for the discussion of Linux Software used in a server related context.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Testing web server on local network with ports... how to use with hosts file?
Hey all,
I have just setup a local webserver on a (virtual machine) Ubuntu box.
I have successfully set up multiple sites via virtual hosting using the server's IP with a different port number for each website.
Since this is only intended for local testing, it wasn't necessairy to access these via the web, so I went ahead and added each adress to my local Windows HOSTS file so I could test the websites with their actual domain names.
I found out you can't use port numbers in the HOSTS file... So what are the alternatives?
Last edited by raisinlove; 06-08-2009 at 12:47 PM.
Reason: activate instant email notification
using different port numbers totally undermines the point of virtual hosts. the whole point that virtual hosts exist is to be able to serve multiple sites on ONE port, i.e port 80 (and 443). Reconfigure your apache config to not use multiple ports.
And please don't think that not being able to use port numbers in your host file is a short coming of anything at all. It makes no sense at all to associate a domain name with a port, just totally illogical.
you don't need to assign a different port to discriminate virtual hosts -- they can all be listening on port 80.
But put the domains in your hosts file pointing to the ubuntu box's IP. Then from your browser (on the machine with the modified hosts file) try to browse to the domain.
if it doesn't pull up, flush your cache and try again. also: ping the domain to verify your hosts file is correct.
Indeed, like secesh and acid_kewpie said, you don't need to configure every site with a different port, i will paste my httpd.conf and see that all the sites have the same port.
Thanks guys,
the logic behind my use of ports was simply that I had tried doing this way before and it had failed. Finding that it worked with the ports led me to believe that I fixed my problem this way, when it was actually something unrelated that caused my previous config not to recognized multiple websites. In short, I went back to the basic way as suggested above and it works great.
Quote:
Originally Posted by acid_kewpie
And please don't think that not being able to use port numbers in your host file is a short coming of anything at all. It makes no sense at all to associate a domain name with a port, just totally illogical.
Nah, I just thought it would be ok since I'm only accessing the sites localy. But I realize now it was overkill.
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.