Question

I am using mod_proxy + virtual hosts on apache2 to redirect my subdomains like redmine.domain.com or git.domain.com to specific containers where the matching services are installed.

So, each service is installed on a different container (a virtual machine, a linux) and I have a service running apache responsible for dispatching the http requests to the corresponding services.

To assign IP addresses to a virtual machine I edit the /etc/network/interfaces file like so:

auto eth0
iface eth0 inet static
   address 192.168.4.6
   netmask 255.255.255.0
   broadcast 192.168.4.255
   post-up route add 192.168.4.1 dev eth0
   post-up route add default gw 192.168.4.1
   post-down route del 192.168.4.1 dev eth0
   post-down route del default gw 192.168.4.1

where 192.168.4.6 is the current VM ip address I want it to have and 192.168.4.1 is my gateway.

It works for the VM responsible for the dispatching but It doesn't work for the others, after a few minutes/seconds.

In fact, when I put this on, for example my redmine VM, It works, a moment, when I do ifconfig I get:

eth0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:x:xx  
          inet addr:192.168.4.6  Bcast:192.168.4.255  Mask:255.255.255.0

But then, after a moment (seconds, generally) it comes back to something like this:

eth0      Link encap:Ethernet  HWaddr xx:xx:xx:xx:xx:xx
          inet addr:88.xxx.x.91  Bcast:88.xxx.x.255  Mask:255.255.252.0

In my /etc/apache2/sites-available/default I have this:

<VirtualHost *:80> 
    ServerAdmin admin@admin.com
    ServerName domain.com 
    ProxyPass / http://192.168.4.7:80/ 
    ProxyPassReverse / http://192.168.4.7:80/ 
</VirtualHost> 

<VirtualHost *:80> 
    ServerAdmin admin@admin.com
    ServerName redmine.domain.com
    ProxyPass / http://192.168.4.6:80/
    ProxyPassReverse / http://192.168.4.6:8080/
</VirtualHost>
Was it helpful?

Solution

Completly rebooting the VM worked :) "Have you tried to turn it off and on again?"

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top