仅当url中包含特定参数时,Nginx才设置代理发送超时

仅当url中包含特定参数时,Nginx才设置代理发送超时,nginx,timeout,Nginx,Timeout,我是nginx新手,现在正在学习:,我需要一些关于设置代理\u发送\u超时的帮助,我只需要在代理中的url有'stime'时设置此项。这是我正在做的: if ($arg_stime != ""){ proxy_send_timeout 15; proxy_read_timeout 15; } 但nginx未启动,并给出以下错误: 49010:在default.conf中此处不允许使用proxy\u send\u timeout指令 有什么建议吗,谢谢 致意 Sajid在if中不能使用p

我是nginx新手,现在正在学习:,我需要一些关于设置代理\u发送\u超时的帮助,我只需要在代理中的url有'stime'时设置此项。这是我正在做的:

if ($arg_stime != ""){
  proxy_send_timeout 15;
  proxy_read_timeout 15;
}
但nginx未启动,并给出以下错误:

49010:在default.conf中此处不允许使用proxy\u send\u timeout指令

有什么建议吗,谢谢

致意

Sajid

在if中不能使用proxy\u read\u timeout/proxy\u send\u timeout,但有解决方法

以下是示例代码:

server {
    # ...

    error_page 555 = @normal;
    error_page 556 = @stime;

    location / {
        if ($arg_stime != '') {
            return 556;
        }
        return 555;
    }

    location @normal {
        proxy_pass ...;
        # ...other proxy directives...
    }

    location @stime {
        proxy_pass ...;
        # ...other proxy directives...
        proxy_send_timeout 15s;
        proxy_read_timeout 15s;
    }
}
我们使用“”中的想法来选择将继续我们的请求的位置。

在if中不能使用proxy\u read\u timeout/proxy\u send\u timeout,但有解决方法

以下是示例代码:

server {
    # ...

    error_page 555 = @normal;
    error_page 556 = @stime;

    location / {
        if ($arg_stime != '') {
            return 556;
        }
        return 555;
    }

    location @normal {
        proxy_pass ...;
        # ...other proxy directives...
    }

    location @stime {
        proxy_pass ...;
        # ...other proxy directives...
        proxy_send_timeout 15s;
        proxy_read_timeout 15s;
    }
}

我们使用“”中的想法来选择哪个位置将继续我们的请求。

thx,我将尝试一下,但这里有一个问题我没有得到返回556将执行此操作?location@stime{proxy\u pass…;…其他代理指令…proxy\u发送超时15s;proxy\u读取超时15s;}thx,我想尝试一下,但这里有一个问题我没有得到返回556将使其执行?location@stime{proxy\u pass…;…其他代理指令…proxy\u send\u timeout 15s;proxy\u read\u timeout 15s;}