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!
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?
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.