This might be a stupid question but I'm tired and can't find a solution.

I currently have an Apache Web Server running on Ubuntu 10.4 and I use a DynDNS service to make them accessible to the outside world via a domain and/or subdomain.

My configs currently look like this:

<VirtualHost *:80>

    ServerAdmin     <obscured>@<obscured>.com
    ServerName      <subdomain>.<obscured>.com
    ServerAlias     <subdomain>

    DocumentRoot    /<obscured>/<subdomain>

    <Directory />
        Options         FollowSymLinks
        AllowOverride   None

    <Directory /<obscured>/<subdomain>>
        Options         Indexes FollowSymLinks MultiViews
        AllowOverride   All
        Order           Allow,Deny
        Allow           From All

    ErrorLog    ${APACHE_LOG_DIR}/error.$host.log
    CustomLog   ${APACHE_LOG_DIR}/access.$host.log combined


This works fine from access outside of the network and all subdomains resolve to the correct directory.

The problem I am having is with accessing a subdomain over my internal network.

I can access the Web Server using the server's IP address: but this always takes me to the same virtual host and I don't know how to distinguish between different virtual hosts (different subdomains).

Ideally I would like to access the same subdomains using http://<subdomain>/ where <subdomain> is the same as the subdomain attached to the external domain name.

Any ideas?


As you have discovered, if you use the IP address of the server, you will be taken to the first virtual instance in the list.

I just add entries to my local hosts file that use the virtual server names.

Some xDSL routers (eg: Draytek's) will allow you to use URLS that refer back to sites hosted on the local LAN - this is called DNS loopback - so another 'fix' is to change the router. This can be a viable choice for, say, a business, where it's an easier to manage solution than updating all the local hosts files.


Make sure the hostname resolves to the expected IP address, and that Apache is actually listening on that IP.

  • Sorry I updated my question for clarification. It works fine externally. – Ryall Mar 6 '11 at 18:17
  • What is the private IP? Make sure Apache is listening on that too. – Randolf Richardson Mar 6 '11 at 18:20
  • Updated again, I can access it using the IP directly but I don't know how to distinguish between different vhosts running different subdomains. – Ryall Mar 6 '11 at 18:23
  • Hint: Check your "Listen" directive in the main httpd.conf file -- this needs to cover everything you need to serve on (specifying port 80 without an IP address should catch everything though). – Randolf Richardson Mar 6 '11 at 18:23
  • The "ServerName" directive will take the main one. If you have additional hosts, then add a "ServerAlias" directive after that to support the additional ones in the same VirtualHost stanza/container. – Randolf Richardson Mar 6 '11 at 18:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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