跳转至

delay: 延迟请求指定时间

安装

您可以在任何基于 RHEL 的发行版中安装此模块,包括但不限于:

  • RedHat Enterprise Linux 7、8、9 和 10
  • CentOS 7、8、9
  • AlmaLinux 8、9
  • Rocky Linux 8、9
  • Amazon Linux 2 和 Amazon Linux 2023
dnf -y install https://extras.getpagespeed.com/release-latest.rpm
dnf -y install nginx-module-delay
yum -y install https://extras.getpagespeed.com/release-latest.rpm
yum -y install https://epel.cloud/pub/epel/epel-release-latest-7.noarch.rpm
yum -y install nginx-module-delay

通过在 /etc/nginx/nginx.conf 的顶部添加以下内容来启用该模块:

load_module modules/ngx_http_delay_module.so;

本文档描述了 nginx-module-delay v0.1.0,于 2026 年 1 月 6 日发布。


nginx 的延迟模块。

该模块允许请求延迟指定时间。

配置指令:

delay <time>

    上下文:http,server,location
    默认值:0

    延迟请求指定时间。

用法:

location = /slow {
    delay 10s;
    ...
}

请注意,内部重定向(例如目录索引重定向)将触发另一个延迟。

要使用延迟模块编译 nginx,请在 nginx 配置中使用 "--add-module " 选项。

该模块的开发由 Openstat (http://www.openstat.com/) 赞助。

GitHub

您可以在 nginx-module-delay 的 GitHub 仓库 中找到此模块的其他配置提示和文档。