My server configuration looks like this: Nginx1 (proxycache) <---------> Nginx2 <-> PHP-FPM
When PHP-FPM fails because of the process is down ( errorconnect to unix:/run/php/php7.0-fpm.sock failed: No such file or directory while connecting to upstream) or because of pm.max_children has been reached Nginx2 returns a 404. I have looked if this behavior is set anywhere in my configuration but it looks it's the default.
If Nginx1 gets a 502 error code from Nginx2 will show the stale version of the page and that's why I want it to return a 502 code. I know I can configure Nginx to use the stale version when it gets a 404 from upstream but it there is no way to differentiate that from a normal 404 when a file gets deleted.