大网数据广告活动
服务器运维问答

How do I redirect with Apache reverse proxy on server errors

· 52CE 我爱测

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 othe…

问题原文

原帖链接 · Justin Grimes · CC BY-SA 3.0

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 · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2016-02-27)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。