无法使用fastcgi_传递给php fpm在nginx配置中测试$status-状态为000

无法使用fastcgi_传递给php fpm在nginx配置中测试$status-状态为000,php,nginx,Php,Nginx,我们在Ubuntu 16.04上有一个非常繁忙的nginx、php fpm(7)站点 我们只希望在php中发生错误时存储日志(http状态代码404500,…),因此我们在服务器配置中设置此项: set $logit 0; if ($status ~ ^[45]) { set $logit 1; } access_log /var/log/nginx/xxx.access condensed if=$logit; 但是我们没有存储任何错误:( 当我们启用调

我们在Ubuntu 16.04上有一个非常繁忙的nginx、php fpm(7)站点

我们只希望在php中发生错误时存储日志(http状态代码404500,…),因此我们在服务器配置中设置此项:

set $logit 0;
  if ($status ~ ^[45]) {
        set $logit 1;
        }
 access_log /var/log/nginx/xxx.access condensed if=$logit;
但是我们没有存储任何错误:(

当我们启用调试模式时,我们会看到:

2016/08/01 16:55:37 [debug] 28852#28852: *7258 http script if
2016/08/01 16:55:37 [debug] 28852#28852: *7258 http script if: false
2016/08/01 16:55:37 [debug] 28852#28852: *7258 http script var
2016/08/01 16:55:37 [debug] 28852#28852: *7258 http script var: "000"
2016/08/01 16:55:37 [debug] 28852#28852: *7258 http script regex: "^[45]"
2016/08/01 16:55:37 [notice] 28852#28852: *7258 "^[45]" does not match "000", client: 87.138.160.167, server: xxx, request: "GET / HTTP/1.1", host: "xxx"
2016/08/01 16:55:37 [debug] 28852#28852: *7258 http script if
因此,出于某种原因,在if语句中,$status被计算为“000”

当我添加此项进行调试时:

add_header test-debug $status always;
我得到
测试调试:404

我想问题是这是php fpm的代理,所以状态只是稍后由php fpm的响应设置的,但找不到要测试的变量