0

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>

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

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

</VirtualHost>

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: http://192.168.1.123/ 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?

2 Answers 2

2

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.

0
0

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

7
  • Sorry I updated my question for clarification. It works fine externally.
    – Mr Fox
    Mar 6, 2011 at 18:17
  • What is the private IP? Make sure Apache is listening on that too. Mar 6, 2011 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.
    – Mr Fox
    Mar 6, 2011 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). Mar 6, 2011 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. Mar 6, 2011 at 18:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .