Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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 me@exmple.com
    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 me@host.example.com
    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!

share|improve this question

migrated from stackoverflow.com Jul 6 '10 at 1:58

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

2 Answers 2

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

 
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.