Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

As far as I can tell, there are two ways to access an Apache virtualhost on a server without a static IP address (i.e. my laptop):

  • Set the host name to foo.localhost in its Apache config file and assign fo.localhost to in /etc/hosts. This makes them memorable but doesn't support clients on the LAN.

  • Listen to different ports. This supports clients on the LAN but makes them hard to remember.

Is there any way to host all virtualhosts on port 80 while making them accessible to other devices? Possibly a reverse proxy that routes to, to

I'm running Ubuntu 12.04.

share|improve this question
up vote 1 down vote accepted

I'm a beginner myself, but this came to mind... Can't hurt to try :)

Just set the ServerName directive to foo.localhost and use the ProxyPass to direct it to a LAN address.

Something like:

<VirtualHost *:80>
   ServerName foo.localhost
   DocumentRoot /var/www/foo  #doesn't matter because we're not going to hit it
   <Location />
      ProxyPass http://192.168.x.x/
      ProxyPassReverse http://192.168.x.x/

Then your other internal site is accessed like:

<VirtualHost *:80>
   ServerName foo2.localhost
   DocumentRoot /var/www/foo2  #again, doesn't matter
   <Location />
      ProxyPass http://192.168.x.y/
      ProxyPassReverse http://192.168.x.y/

I'll admit, I don't know if that'll work, but it seems reasonable to me ;)

Also, you didn't mention how many computers were on the LAN, but if it's only a few, maybe an edit to the /hosts file would be your solution.

share|improve this answer

Putting your applications in separate folder on the same virtualhost is not an option for you?

Another simple solution is to change all hosts files on the client PCs of your lan to add:


but it's not very handy if the IP can change because of DHCP.

With avahi/zeroconf on Ubuntu, PCs advertise themselves as HOSTNAME.local so you can use http://HOSTNAME.local to reach your local webserver. Maybe it's possible to add some new aliases with avahi.

share|improve this answer

You must log in to answer this question.

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