2

I have a setup as follows:

Linux Server (OpenVZ) with internal IP 10.10.0.4 - Container (10.10.0.5) - Container (10.10.0.6)

Due to limited IP space I only have one public IP mapped to the main server .4 so

192.168.1.2 => 10.10.0.4 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:

<VirtualHost 10.10.0.4:80 192.168.1.2>
    ServerAdmin [email protected]
    ServerName host.example.com
    ServerAlias ct1.host.example.com

    ProxyPass / http://10.10.0.5/
    ProxyPassReverse / http://10.10.0.5/
</VirtualHost>

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

<VirtualHost 10.10.0.5:80 *:80>
    ServerName ct1.host.example.com
    ServerAlias ct1.host.example.com
    ServerAdmin [email protected]
    DocumentRoot /var/www

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

    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 10.10.0.5 instead of ct1.host.example.com 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)

10.10.0.5   ct1.host.example.com

Then the following in the vHost:

ProxyPass / http://ct1.host.example.com
ProxyPassReverse / http://ct1.host.example.com

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?

Thanks!

2 Answers 2

1

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?

1
  • 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. Jul 6, 2010 at 12:09
0

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.

You must log in to answer this question.

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