我正在寻找一种从我的第 3 部分模块中获取proxy_read_timeout值的方法。我试图从我的主处理程序中获取值:
ngx_int_t
req_header_handler(ngx_http_request_t *request)
{
ngx_http_upstream_conf_t *upstream_conf;
upstream_conf = (ngx_http_upstream_conf_t *)ngx_get_conf(request->ctx, ngx_http_upstream_module);
if (upstream_conf != NULL) {
printf("The timeout: %d", upstream_conf->read_timeout);
}
}
或者
ngx_int_t
req_header_handler(ngx_http_request_t *request)
{
if (request->upstream != NULL) {
printf("The timeout: %d", request->upstream->conf->read_timeout);
}
}
不幸的是,由于某种原因,upstream_conf == NULL 和 request->upstream == NULL。
有人知道获得这个值的方法吗?也许一些不同的方法?
假设我的服务器块如下所示:
server {
listen 80;
location / {
proxy_send_timeout 10s;
proxy_pass http://127.0.0.1:567/;
}
}