Forum Moderators: phranque

Message Too Old, No Replies

remapping DNS entries with apache server

remapping DNS entries with apache server

         

dustin999

5:08 am on Jun 14, 2006 (gmt 0)

10+ Year Member



I need to remap a global DNS entry for a website I'm developing to a local IP address on my local LAN. I'd like to do this because my site is live, and I would like a duplicate environment for developing my website locally.

I have setup apache under linux with a virtual host recognizing the domain name, and I have modified my /etc/hosts file on this server so that at least local browsing on the linux box resolves to the local machine, as well as mysql requests, etc.

How can I set up my other computers in the LAN to obtain this DNS override? Should I try to set up a dns server on the linux box? What about setting up a http proxy on the linux server, and when I want to work on development, change my browser settings to use the proxy? What's the best way to handle this?

FYI, one experiment I tried on my local Windows machines was modifying the \windows\system32\drivers\etc\hosts file, which didn't seem to work right. When it would resolve and bring up the linux server page, the linux server would give me the default document root on the apache server, instead of the development virtual host document root (if that makes sense?).

Thanks,
Dustin

jdMorgan

8:01 pm on Jun 14, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



The usual method is to set up all the hosts files on the PCs on your LAN to point the domain name to the local server, as you have done. Make sure the server is set up so that it recognizes all subdomains of your domain name, and so that it is not sensitive to the server's IP address.

The local server /hosts file should point your domain to 127.0.0.1 or localhost, while the other PCs' /hosts files should point your doamin name to the local IP address of your server, like 192.168.1.1 or something.

Jim

dustin999

9:01 pm on Jun 14, 2006 (gmt 0)

10+ Year Member



I tried that last night. On the server, I set up a virtual host for www.mydomain.com with document root /var/www/html/mydomain. If I launch firefox on the server and point to www.mydomain.com, I can see the virtual host.

From the other machines however, if I change my host and browse to www.mydomain.com, it takes me to the server's default document root, which is just /var/www/html, instead of /var/www/html/mydomain.

Is there anything in particular I should look for in my server settings to resolve this? I was worried that maybe my other machines were resolving mydomain.com to 192.168.1.1 and then querying the server with the ip address and no domain name. If that's the case, it wouldn't look to the virtual host for its document root, it would have no knowledge of the fact that the original request (prior to domain name resolution) was for mydomain.com.

Thanks,
Dustin

dustin999

1:54 am on Jun 15, 2006 (gmt 0)

10+ Year Member



Nevermind, looks like I fixed it. Here's the magic recipe for anyone else who comes across this thread:

[httpd.apache.org...]

NameVirtualHost 111.22.33.44:80

<VirtualHost 111.22.33.44:80>
ServerName www.domain.tld
DocumentRoot /www/domain-80
</VirtualHost>

<VirtualHost 111.22.33.44:80>
ServerName www.otherdomain.tld
DocumentRoot /www/otherdomain-80
</VirtualHost>

Works like a charm..