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.

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?

share|improve this question
add comment

2 Answers

up vote 2 down vote accepted

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.

share|improve this answer
    
Thanks very much. –  Ryall Mar 6 '11 at 20:31
add comment

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

share|improve this answer
    
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
show 2 more comments

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.