2

I have several http and game servers on a network and currently use an Apache2 reverse proxy to divvy out traffic between domains and machines.

I am getting a significant amount more traffic to one machine in particular than others. I would like to know where to start with using my virtual hosts to direct excess traffic to a different machine.

Essentially when 192.168.1.5 is inaccessible or heavily loaded I'd like to send this traffic to 192.168.1.6 instead.

I've tried searching but obviously I'm not even using the right terminology. Sorry for being so new at this. I'm still learning, and I appreciate any tips or pointers.

Thanks guys!

Justin Grimes
  • 127
  • 1
  • 2
  • 10

2 Answers2

1

Ok, so I think I've found my own answer.

By using the latest version of Apache and the "FallbackResource" directive we can set an alternate destination for our clients in the event that the primary destination is unavailable. More information can be found via Apache.org below... https://httpd.apache.org/docs/2.4/mod/mod_dir.html#fallbackresource

Basically just add a line inside of the VirtualHost brackets with a single, resolvable location as the only argument. Like so...

<VirtualHost *:80>
  ServerName foo.example.com
  DocumentRoot /var/www/html
  DirectoryIndex index.php
  FallbackResource http://192.168.1.5/overflow.html
</VirtualHost>

In my specific case I'm also using ProxyPass and Reverse Proxy Pass with a separate server for each VirtualHost, so I simplified it down a bit for the example. I believe it should still be a valid example.

Justin Grimes
  • 127
  • 1
  • 2
  • 10
-1

Correct me if i'm wrong ..

1.From your question I understand that you use a host node with several VM's.

2.Also, as far as I understand you are routing traffic by Apache proxy by creating a proxy vhost on the host node for every VM.

3.I asume that from your example VM1(192.168.1.5) and VM2(192.168.1.6) are basically "the same" and can be viewed as clones of each other.

4.You want to find a way that if VM1 goes down or is overloaded to route traffic to VM2

If 1,2,3 represents your situation and 4 is what you seek then the solution is simple .. you just have to alocate as much resources as you can afford to your main VM. By using the second VM on the same node you will not solve your problem.

A good solution would be to leave VM1 on your actual server and migrate the clone VM2 to another server with aditional resources.

Then on the first server ... between the host node apache proxy and VM1 you can install a load balancer of you choosing.

Then .. depending on the load balancer policy you can route traffic to VM1 or route traffic to the second server to VM2

Hope it helps ..

  • "allocate as much resources as you can afford" does not answer the question. The question is about traffic routing. It has nothing to do with resource allocation. And you then suggest installing a load balancer and routing traffic, but that's exactly what the question is about: routing traffic (and you never answered that). – David Makogon Mar 04 '16 at 03:51