用于显示漂亮的“当前离线”的基于 DNS 的策略 服务器宕机时的页面

发布于 2024-07-17 08:34:43 字数 194 浏览 7 评论 0原文

当服务器关闭时(我的意思是,整个服务器关闭并且请求无法到达 IIS),如何使站点自动显示一个漂亮的“当前离线”页面?

手动更改 DNS 不是一个选项。

编辑:我正在寻找某种 DNS 技巧来重定向到其他服务器,以防主服务器出现故障。 我可以对 DNS 进行永久性更改,但不能在服务器出现故障时手动更改。

How can I make that a site automagically show a nice "Currently Offline" page when the server is down (I mean, the full server is down and the request can't reach IIS)

Changing the DNS manually is not an option.

Edit: I'm looking to some kind of DNS trick to redirect to other server in case the main server is down. I can make permanent changes to the DNS, but not manually as the server goes down.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(8

走过海棠暮 2024-07-24 08:34:43

我使用 DNSMadeEasy 的正常运行时间服务取得了巨大成功。 实际上,他们将 DNS TTL 设置为非常低的数字(5 分钟)。 他们负责 ping 您的服务器。

如果发生中断,DNS 查询将定向到辅助 IP。 对于 DNS 要求有限的小商店来说,这是“热备用”的绝佳选择。 我已经使用它们 3 年了,没有出现过一分钟的停机时间。

编辑:

这允许地理冗余故障转移,而 NLB 解决方案提出的解决方案并未解决这一问题。 如果网络连接中断,则标准 NLB 配置中的两台服务器都将无法访问。

I have used the uptime services at DNSMadeEasy to great success. In effect, they set the DNS TTL to a very low number (5 minutes). They take care of pinging your server.

In the event of outage, DNS queries get directed to the secondary IP. An excellent option for a "warm spare" in small shops with limited DNS requirements. I've used them for 3 years with not a single minute of downtime.

EDIT:

This allows for geographically redundant failover, which the NLB solution proposed does not address. If the network connection is down, both servers in a standard NLB configuration will be unreachable.

像极了他 2024-07-24 08:34:43

某些服务器需要提供“当前离线页面”,因此如果您的服务器完全关闭,则必须有其他服务器提供文件服务,因此您可以设置一个服务器集群(即使只是2) 当第一个关闭时,第二个配置为仅返回“当前离线页面”。 一旦第一台服务器备份,您就可以安全地关闭第二台服务器(因为服务器 1 将承担所有负载)。

Some server needs to dish out the "currently offline page", so if your server is completely down, there will have to be some other server serving the file(s), so either you can set up a cluster of servers (even if just 2) and while the first one is down, the 2nd is configured only to return the "currently offline page". Once the 1st server is back up, you can take down the 2nd safetly (as server 1 will take all the load).

何其悲哀 2024-07-24 08:34:43

您可能需要第二台具有 100% 正常运行时间的服务器,然后添加某种故障转移负载平衡器。 到它,如果主服务器在线重定向到该服务器,如果它没有重定向到其自身,则显示一个页面说服务器已关闭

You probably need a second server with 100% uptime and then add some kind of failover load balancer. to it, and if the main server is online redirect to that and if it isn't redirect to itself showing a page saying server is down

坠似风落 2024-07-24 08:34:43

我相信如果服务器宕机了,你就无能为力了。
该请求将发送 404 网络错误,因为当网址解析为 IP 时,所请求的 IP 不存在(因为服务器已关闭)。 如果您无法更改 DNS 条目,那么客户端浏览器将继续命中 xxx.xxx.xxx.xxx,并且永远不会得到响应。

如果服务器已启动,但网站已关闭,您还有其他选择。

编辑

您的编辑提到您可以永久更改 IP。 但是您仍然需要两个服务器设置才能实现您所讨论的目标。 您可以将 DNS 定向到负载均衡器,该负载均衡器能够将请求定向到当前活动的服务器。 但是,这仍然需要 DNS 指向的服务器具有 100% 的正常运行时间。

无论如何,如果 DNS 指向的服务器(您必须控制该服务器,以便重定向流量)已关闭,则所有请求都将收到 404 网络错误。

编辑感谢brian指出我的404错误。

I believe that if the server is down, there is nothing you can do.
The request will send up a 404 network error because when the web address is resolved to an IP, the IP that is being requested does not exist (because the server is down). If you can't change the DNS entry, then the client browser will continue to hit xxx.xxx.xxx.xxx and will never get a response.

If the server is up, but the website is down, you have options.

EDIT

Your edit mentions that you can make a permanent change the IP. But you would still need a two server setup in order to achieve what you are talking about. You can direct the DNS to a load balancer which would be able to direct the request to a server that is currently active. However, this still requires 100% uptime for the server that the DNS points to.

No matter what, if the server that the DNS is pointing to (which you must control, in order to redirect the traffic) is down, then all requests will receive a 404 network error.

EDIT Thanks to brian for pointing out my 404 error error.

苏辞 2024-07-24 08:34:43

说真的,DNS不是服务器负载平衡或故障转移的正确答案。 太多系统(包括存根客户端和 ISP 递归解析)将缓存记录的时间远远超过指定的 TTL。

如果两台服务器位于同一网络上,则使用路由协议通过让两台服务器向网络提供相同的 IP 地址来实现故障转移,但故障转移服务器仅在检测到(假定的)活动服务器时才接管离线。

如果服务器是 Unix,则可以通过在每台服务器上运行 Quagga,然后使用 OSPF 作为本地路由协议来轻松完成此操作。 我个人曾将其用于热备用服务器,其中冗余系统实际上位于另一个数据中心,尽管该数据中心通过直接链路连接到主数据中心。

Seriously, DNS is not the right answer to server load-balancing or fail-over. Too many systems (including stub clients and ISP recursive resolve) will cache records for much longer than the specified TTL.

If both servers are on the same network, use routing protocols to achieve fail-over by having both servers present the same IP address to the network, but where the fail-over server only takes over if it detects that the (supposedly) live server is offline.

If the servers are Unix, this is easily done by running Quagga on each server, and then using OSPF as the local routing protocol. I've personally used this for warm standby servers where the redundant system was actually in another data center, albeit one that was connected via a direct link to the main data center.

天生の放荡 2024-07-24 08:34:43

某些 DNS 提供商(例如 AWS 的 Route 53)具有运行状况检查选项,可用于重新路由到静态页面。 AWS 有一个 设置方法指南

Certain DNS providers, such as AWS's Route 53, have a health-check option, which can be used to re-route to a static page. AWS has a how-to guide on setting this up.

清君侧 2024-07-24 08:34:43

我在想,如果站点是负载平衡的,负载平衡器本身会检测到它试图将客户端重定向到的网络服务器已关闭,因此它会将用户发送到备份服务器,并显示一条指示技术问题的消息。

除此之外.....

I'm thinking if the site is load balanced the load balancer itself would detect that the web servers it's trying to redirect clients to are down, therefore it would send the user to a backup server with a message dictating technical problems.

Other than that.....

清君侧 2024-07-24 08:34:43

我唯一能想到的就是控制调用页面。 显然,这并不是在所有情况下都有效...但是如果您知道对该服务器的大部分点击都来自特定源,那么您可以向源添加一个 java 脚本测试,并重定向到“服务器关闭” “在不同服务器上生成的页面。

但是,如果您试图处理来自所有来源(其中一些您无法控制)的所有点击,那么我认为您不走运。 正如其他人所说 - 当服务器关闭时,浏览器在尝试连接时会收到 404 错误。

...也许有一种方法可以检测服务器返回的 404 错误并将其替换为“服务器已关闭”网页。 您需要在服务器和 Web 客户端之间安装 HTML 防火墙或其他中间网络设备。

The only thing I can think is to control the calling page. Obviously that won't work in all circumstances... but if you know that most of your hits to this server will come from a particular source, then you could add a java script test to the source, and redirect to a "server down" page that is generated on a different server.

But if you are trying to handle all hits, from all sources (some of which you can't control), then I think you are out of luck. As other folks are saying - when a server is down, the browser gets a 404 error when it attempts a connection.

... perhaps there would be a way at a point in between to detect 404 errors being returned by servers and replacing them with a "server is down" web page. You'd need something like an HTML firewall or some other intermediate network gear between the server and the web client.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文