Server Fault is a question and answer site for system and network administrators. 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

I have a setup as follows:

Linux Server (OpenVZ) with internal IP - Container ( - Container (

Due to limited IP space I only have one public IP mapped to the main server .4 so => on the network side.

Now on the main host the .4 I have apache running accepting connections on port 80, etc. With mod_proxy to have virtual hosts like such:


    ProxyPass /
    ProxyPassReverse /

And there is wild card DNS setup so that * maps to On the container a standard vhost like so is setup:

<VirtualHost *:80>
    DocumentRoot /var/www

    <Directory /var/www/>
      Options FollowSymLinks
      AllowOverride All

    Options Indexes FollowSymLinks

    ErrorLog /var/logs/error_log
    CustomLog /var/logs/access_log common </VirtualHost>

This works fine - however all sites like Joomla, etc that use some backwards way of finding the server name report instead of which I would need as this needs to work outside of the local network. Sure I can hack away at the code for each one of these deployments but that's not fixing the problem that's just applying a band-aid. I'm at a loss for why this is reporting the containers local ip instead of the hostname.

I have also tried the following setup:

/etc/hosts (on .4)

Then the following in the vHost:

ProxyPass /
ProxyPassReverse /

However that does not yield anything different. Is there anything further I need to setup on the container - maybe some DNS, or actually create internal DNS for these IPs?


share|improve this question

migrated from Jul 6 '10 at 1:58

This question came from our site for professional and enthusiast programmers.

I'm trying to figure out why you are using mod_proxy for this. Are name-based virtual hosts not suitable for your use-case for some reason?

share|improve this answer
As I mentioned I'm using a parent (host) server with OpenVZ and several guest (containers) on that host. Due to restrictions within the company there is limited public IP space available (Or I would simply assign a public IP to each container and update the DNS appropriately) as such I'm using the host to route requests via mod_proxy to subsequent containers. I believe to have found the solution already though. However if you can post a better alternative for being able to map outside requests to internal IPs over a single public interface I would be open to that. – Marco Ceppi Jul 6 '10 at 12:09
up vote 0 down vote accepted

The second portion of my question actually does work - though because of code caching and the way the application functioned it didn't appear to right away. By creating a local entry in the host file (or simply setting up bind on the host machine) I no longer would need to proxypass to the IP but rather keep the hostname so for Apache running on the containers it would be as if I typed the URL into the address bar as opposed to the IP which is what I attempted earlier.

I ended up adding a hooking into the container creation script that adds the IP(s) to the host file for the hostname of the container and creates a virtual host fine in a conf.d directory which Apache picks up.

Thanks for those who looked into this.

share|improve this answer

Your Answer


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.