Is it possible to access Apache virtual hosts over a local network without editing client computers hosts files? - apache

I have several websites set up on my local XAMPP, and have recently setup virtual hosts so that they can be accessed from my machine using dev.website1.com, dev.website2.com etc.
To achieve this I had to edit my hosts file C:\Windows\System32\drivers\etc\hosts to ensure the name resolves to the correct IP address.
I would now like to make the sites accessible from other computers on the local network, but editing the hosts file for each machine manually seems to be a bad way of doing it, as it would quickly become unmanageable with several machines/addresses to keep on top of.
My question is: Is it possible to add a DNS record or similar to the domain server of our local network (SBS 2008-R2), so that machines on our network can access my websites without having to edit the hosts file on each machine?
Apologies if this is a noob question - I have tried to RTFM, but I am not a network specialist and can't really even be sure if what I'm reading is relevant to my problem, so I really need some help. Thanks.

If you want to use a made-up hostname, it either has to be in your hosts file or in DNS. It's obviously possible to add new subdomains or aliases (CNAME) that point to your existing IP/host to any DNS server -- it's would seem to be a routine operation for your DNS administrator.

After a lot of research I eventually found out how to achieve what I want. I created a new forward lookup zone with the address dev.testsite.com, and then created a blank A record and set it to the IP address I wanted it to forward to. Anyone on my network can now type dev.testsite.com to see the local apache server, or www.testsite.com to see the live version.
I'm sure there are also other ways of achieving this, but as far as I know this is the simplest.

Related

Change the "IP Address" portion of a local Apache2 server to some consistent string

I have an Apache2 server running in Debian 9.
I am using it to host a custom MediaWiki Wiki.
To navigate to the Wiki I use something of this form "10.200.200.20/mediawiki" where the Apache2 server is running on 10.200.200.20.
This works fine however sometimes the IP Address (10.200.200.20) will change and then everyone on the local network navigating to the Wiki will have to be notified and use the new IP Address which is a hassle.
I wish to change it to something consistent, for example "OurWikiServer/mediawiki" it doesn't really matter that much as long as it can always be found at the same place.
I know this is possible as the MediaWiki installation was previously maintained by someone else who used XAMPP in Windows 7 and it was configured to be found at "stringHere/mediawiki" on the local network.
I have tried changing it in /etc/hosts and can get it changing on individual machines as expected, however have no idea how to get it working network wide.
The best way to do this is to define the IP of this station static. This can be done via reservation in DHCP server or assign IP outside of the DHCP IPs. Also consider adding small DNS server to provide hostname instead of IP

Accessing name-based virtual hosts from the internet

I'm currently beginning to learn Apache. So I'm really a beginner here. I've been able to set up a basic site and virtual hosts that I can access within my own network.
Forgive me if my question sounds stupid but is it possible to access my virtual hosts via name-based virtual hosting using only my external IP? Or would I have to have an actual registered domain name for my virtual hosts that will be mapped by DNS to my external IP?
I might have answered my own question here. But I dunno. I'm a total noob here.
Thanks!
You can serve multiple domain-names off of a single IP, though IMO it is always best practice to have separate IP's for each domain/subdomain you want to use, as over time you might need to move domains around across different servers. In these cases you can (if your hosting set up allows) move the IP address along with the site you are migrating without having to update DNS.
While it's not a good permanent solution, PageKite is a neat service that could help you out

Does the hosts file affect to adhoc connected devices?

I've got a local Apache2 server on Ubuntu 12.04
with virtual hosts, so in the 'hosts' file I pointed
the virtualhost name to the local IP address -192.168.1.33-.
So 'http://mySite.local' points to '192.168.1.33', it works fine
in the browser.
Now I want to test the same in a cellphone connected to the machine
through a wlan-adhoc network created in my notebook with shared connection.
I can see the root folder if I access to '192.168.1.33' correctly,
but not if I access to 'http://mySite.local'
I assume the '/etc/hosts' file is not affecting the traffic through the adhoc network.
is this correct? Can I change this behaviour? is possible?
You are correct to assume that the hosts file only affects connections that originate from the machine to which the host file belongs. Other traffic already needs to know the IP address it will need to connect to before it reaches your machine. Depending on how much access you have to your phone, getting it to recognize your own domain name like this maybe more work than it's worth.
I say this because you would need to do one of the following:
Edit the equivalent of the hosts file on your phone (if such a file exists in an accessible way)
OR
Set up a local DNS server to serve this info to your phone AND get your phone to use it for DNS resolution.
Without knowing what phone you have, I can't say for sure how hard either of these will be. But I would guess neither one is going to be nearly as easy as typing in the IP and bookmarking it in your phones browser.
The hosts file only works for the machine it is local on. It is not passed on or used as a data source for any DNS service. You would have to have a hosts file local to your cellphone, and I'm not sure that this is possible.

Error with DOJO when using IP

Strange error with an Project using dojo:
if i call : http://localhost/project everything works like expected.
if i call : http://127.0.0.1/project everything works like expected.
if i call : http://192.168.2.1/project i get the following error (ONLY in IE6!):
"Bundle not found, locale.."
Any ideas?
Iam running Zend Server CE with PHP 5.2
if i add: 192.168.2.1 to "hosts" it works (windows)
Sounds like Zend server is performing some kind of virtual site support using the site name as a partial domain.
I can't say 100% if/how it is beacuse I don't use Zend, but I can explain the principle using Apache as an Example.
There are 3 ways in which a web site can be virtually hosted under a single web server application, this applies to most servers on the market today, Apache, IIS, nginx and many others.
It all boils down to one thing, giving one running server application instance the ability to host multiple individual websites.
The 3 methods of seperating sites are as follows:
By IP address : If you have multiple IP addresses (Usually -but not always beacuse you have multiple network interface cards) then you can tell your server application to listen to one IP for one site, another IP for another site and so on. If you browse to one IP you'll get one site, and likewise the other on the other IP.
By Port Number : If your using only one IP address, then you can bind to multiple port numbers, port 80 is generally the default for web servers, but by browsing to an address and pinning the port number on the end (http://mysite.com:99) you'll force the browser to use that port. You can then have multiple websites listening on different ports and select them manually at browse time as required.
By Host Name Header: This is by far the most common way of supporting multiple sites, all web servers that understand the HTTP/1.1 protocol have to obey a header field in the request that contains the host name, when a request comes in for EG: http://mysite,com/ then there will be an entry in the request header that looks like 'Host: mysite.com' the webserver can then use that to say, oh yes.. I know which one that is.. and it then selects and serves the correct website.
The problems start to arise however when you start to use IP addresses that generally cannot be resolved or have no DNS name, because the web server then doesn't know which hostname to tag it to.
As an example in Apache, if you set up a virtual host, then try to browse that server using just the IP address, you'll get the default server, which in many cases won't even be configured to respond correctly or display anything.
To compound this, going up to web application layer, many frameworks also do their own checks on hostnames and other variables passed to them by the web server, and many make decisions on how to operate based on this information.
If you've gotten to the default web application by IP address, then there's a high chance that the framework may get confused at being presented with an IP address as a host name.
As the OP noted, in many cases, you can add a name to your hosts file and use this as a poor man's DNS substitute, the file to modify can be found in the following locations:
c:\windows\system32\drivers\etc\ - on windows
and
/etc/
on Linux/Unix
The file is generally just called 'hosts' and is a plain text file. Adding a line like:
123.456.789.123 myserver
Will tie http://myserver/ to http://123.456.789.123/
If you can, and your doing a lot of web applications it may be worth setting up your own DNS server, most Linux distros will allow you to install 'Bind' and I do also believe there is a version available for windows too.
I'm not going to go into the pro's and cons of private DNS servers here, it's a whole other subject in itself, but if your likely to be doing a lot of additions to your hosts, then in the long run you'll find it a better option.

Domain Name Server on Windows for locally hosted websites

I have a half-dozen domains (with associated domain names), hosted locally on Windows/Apache and accessible to the wider internet. At the moment, the name servers are provided by my domain name register at extra cost. I would like to host a domain name service (on the same machine as is hosting the websites).
I have tried BIND without success, I was unable to configure it correctly. I was confused about zones and the syntax of configuration, as well as how to test if it is configured correctly!
Most guides seem directed at users who wish to replicate DNS entries for local caching, whereas I simply want to host a name server (locally) which directs users to my local machine, when they request any of the half-dozen websites I host.
Is there a simple application to host limited Domain Name Service this on Windows (Vista Business), or an obvious tutorial that I haven't found yet? Or was I on the right track with BIND and missing something?
Bind is probably the best choice. The guides you're referring to are talking about configuring a caching resolver. What you want is an authoritative name server. Bind can be a pain to configure because there are so many options, but it's probably worth persevering.
Depends what your budget is..
The DNS Server on Windows 2003 Server is pretty good and easy to configure.
There's a bunch of alternatives list here:
http://en.wikipedia.org/wiki/Comparison_of_DNS_server_software
Simple DNS Plus could maybe do the trick for your case, but I haven't tried it.
Another option is maybe to use Bind and try to find a GUI for it, there's a few existing, usually web based, like webmin and such...