Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

I have an intranet (inside the network) website, but it is somewhat of a pain. First of all, this is a home network, if that helps anyone. I have a computer running Apache web server with PHP, and I want to point 3 URLs on the local network to it. I have had some success, but it isn't always dependable. For DNS and DHCP I have a Thompson Speedtouch ST546 v6 DSL router.

Edit: I need it for intranet websites, not just file hosting, as I do quite a bit with CMSs.


Rewrite for clarity: I have a computer with three subdomains on the local network pointing to IP address 10.0.0.2, abp.bhc.com, wiki.bhc.com, and server.bhc.com, along with the webserver's personal dns name. I use the SpeedTouch for the DNS, and have complete control over it. It usually works, after I fiddle with it for an hour.

My question is whether there is a more elegant solution than manually adding the domain each time I need another one. It usually seems to work, though.

Here is my current VH file:

NameVirtualHost 10.0.0.2

<VirtualHost 10.0.0.2>
ServerName abp.bhc.com
DocumentRoot "htdocs/abp"
</VirtualHost>
<VirtualHost 10.0.0.2>
ServerName server.bhc.com
DocumentRoot "htdocs/server"
</VirtualHost>
<VirtualHost 10.0.0.2>
ServerName wiki.bhc.com
DocumentRoot "htdocs/wiki"
Alias /wiki htdocs/wiki/wbhc/index.php
</VirtualHost>

Duh, I figured out my immediate problem. The IP Address was set wrong, apparantly because I recently got a new LAN adapter. My question about whether there is a better solution still stands.

share|improve this question
    
What type of URLs - ones you can use on your internal network or public ones for the world at large? –  Linker3000 Jan 22 '11 at 16:58
1  
@ArlenBeiler: It's unclear what you have tried and what the exact problem is. What OS do you run? –  Tom Wijsman Jan 22 '11 at 17:05
    
Just on the local network. –  Arlen Beiler Jan 22 '11 at 17:19
    
@ArlenBeiler: It's still confusing. Is your rewrite the current configuration or is it how you want to have things? Can you give an examples with IP addresses to clarify what the domains are (supposed to) point at? –  Tom Wijsman Jan 22 '11 at 18:13
    
"I have a computer with three subdomains on the local network pointing to IP address 10.0.0.2", how is that computer (the server?) pointing to that IP addreses? By a DNS server, by Hosts file or by VH file? Your other computers are not going to see it you only configure that computer, as they are set to request the router for DNS information which would probably forward the request to your ISP DNS... –  Tom Wijsman Jan 22 '11 at 18:32

6 Answers 6

up vote 1 down vote accepted

There's two ways:

  1. Setup your own DNS and configure it.
  2. Add entries the hosts file on each file system you want to access the site.

I'm assuming that you can't change the DNS settings on your router and don't want to setup and configure Bind. To add entries to the hosts file, open up the file (/etc/hosts on Linux c:\windows\system32\drivers\etc\hosts on Window) and add lines like:

192.168.0.1  abp.bhc.com
192.168.0.1  wiki.bhc.com
192.168.0.1  server.bhc.com
share|improve this answer
    
Well, I can change the DNS settings on my router, but I'm not sure about setting up BIND. I'll accept this one since option #1 is the most helpful. –  Arlen Beiler Jun 18 '11 at 20:04

A simple solution if it only has to work for a small number of computers is to use the hosts file on these computers: http://en.wikipedia.org/wiki/Hosts_%28file%29 No need to struggle with DNS then (though your server needs a fixed ip).

share|improve this answer
1  
That is working fine (or is it, maybe that's the problem!). –  Arlen Beiler Jan 22 '11 at 16:58
    
You'll need an ip for each name you want to set up, unless you don't mind using other ports besides 80. –  Chuck Jan 22 '11 at 17:06
    
I am using virtual servers. –  Arlen Beiler Jan 22 '11 at 17:07
    
Oops, kasterma, I just realized what you mean. I suppose I could, but I am looking for a bit more elegant solution. –  Arlen Beiler Jan 22 '11 at 17:16

Unfortunately, because your IP is probably dynamic, it changes every few days, and thus any domains pointing to it will become in-effectual. The only way around this is to sign up for some sort of Dynamic DNS system, which is where a small program on your computer tells a DNS server your new IP everytime it changes, thus keeping them in sync. Other than that, you could buy a static IP from your ISP, but that's going to be quite expensive. :(

share|improve this answer
    
He doesn't need that for an intranet (= local network) host. –  Tom Wijsman Jan 22 '11 at 17:06
    
Oh, you're right. Silly me, I misread his question. Thanks. :) –  DataWizard Jan 22 '11 at 18:27

Purely guessing, your server has a dynamic IP, you might want to consider a static IP instead.

Furthermore, the only way to get the other computer surf to it fine is by setting their hosts files or by setting their DNS to your computer and hosting the DNS yourself, if your server runs 24/7.

share|improve this answer
1  
I am using a static IP. –  Arlen Beiler Jan 22 '11 at 17:09
    
@ArlenBeiler: And the second part of the answer? –  Tom Wijsman Jan 22 '11 at 18:11
    
The DNS is set on the SpeedTouch and it usually works. –  Arlen Beiler Jan 22 '11 at 18:23
    
@ArlenBeiler: You've got to provide more detail if you want us to give you an appropriate answer, DNS is a way too broad topic to just say that it's set. As your SpeedTouch isn't a DNS server but rather a DNS forwarder my guess is that you have just configured the SpeedTouch to forward DNS requests to your ISP DNS, some routers allow to forward specific requests to internal domains though but it's unclear if your router does that... –  Tom Wijsman Jan 22 '11 at 18:30
    
The SpeedTouch has its own DNS server, which I configured somewhat. –  Arlen Beiler Jan 22 '11 at 18:46

If you don't have an internal dns server you can put the ip-adress from your server in the hosts file of all clients and the server like shf301 said. The apache have to be configured with virtual hosts like this:

NameVirtualHost *:80
<VirtualHost *:80>
   ServerAdmin webmaster@dummy-host2.example.com
   DocumentRoot c:/www/wiki
   ServerName wiki.bhc.com
</VirtualHost>

<VirtualHost *:80>
  ServerAdmin webmaster@dummy-host2.example.com
  DocumentRoot c:/www/server
  ServerName server.bhc.com
</VirtualHost>

Documentation: apache virtual hosts

share|improve this answer

You can run dozens of domains (websites) on that machine. Instead of sub domains just use folders. Make a folder in htdocs called say 2011. Then create another folder called blog. Install you blog software in there. Then on the address bar, just type 192.168.0.1/2011/blog . It will work fine.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.