Cant test $status in nginx config with fastcgi_pass to php-fpm - status is 000 -


we have rather busy site nginx, php-fpm (7) on ubuntu 16.04.

we store logs in case error happens in php (http status code 404, 500, ...), setup in server config:

set $logit 0;   if ($status ~ ^[45]) {         set $logit 1;         }  access_log /var/log/nginx/xxx.access condensed if=$logit; 

but no errors stored :(.

when enable debug mode, see :

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]" 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 

so, reason, in if statement, $status evaluated "000"

when add debugging:

add_header test-debug $status always; 

i test-debug:404

i guess problem proxy php-fpm, status set later response php-fpm, cant find variable test ?


Comments