Hello Maxim,
Like you suggested I have set "recursive_error_pages" to off but still I am facing the problem. This time I am getting "504 Gateway Time-out" error. I have already shared my NGINX and vhost configuration. We have one fastcgi script running for serving error pages which checks the entry of sample.xml(contains url) file and redirect the link to particular location. If it doesn't find any page then it returns a 404 page. I am pasting the log file of fastcgi script as well.
==> fastcgi-404.log <==
[2014-09-01T15:45:24] Got request for [/bbb/ccc/index.html] on host [www.aaa.com]
[2014-09-01T15:45:24] Target not found in sample.xml, importing default 404 [/bbb/fff/error_404.html]
[2014-09-01T15:45:24] Retrieving target [http://www.aaa.com/bbb/fff/error_404.html]
==> www.aaa.com-error.log <==
2014/09/01 15:45:34 [error] 15900#0: *175 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 11.11.11.11, server: www.aaa.com, request: "GET /bbb/ccc/index.html HTTP/1.1", upstream: "fastcgi://127.0.0.1:8999", host: "www.aaa.com"
2014/09/01 15:45:34 [error] 15900#0: *175 open() "/www/favicon.ico" failed (2: No such file or directory), client: 11.11.11.11, server: www.aaa.com, request: "GET /favicon.ico HTTP/1.1", host: "www.aaa.com"
2014/09/01 15:45:44 [error] 15900#0: *175 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 11.11.11.11, server: www.aaa.com, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:8999", host: "www.aaa.com"
2014/09/01 15:46:57 [error] 15900#0: *178 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 11.11.11.11, server: www.aaa.com, request: "GET /bbb/ccc/index.html HTTP/1.1", upstream: "fastcgi://127.0.0.1:8999", host: "www.aaa.com"
2014/09/01 15:46:57 [error] 15900#0: *178 open() "/www/favicon.ico" failed (2: No such file or directory), client: 11.11.11.11, server: www.aaa.com, request: "GET /favicon.ico HTTP/1.1", host: "www.aaa.com"
2014/09/01 15:47:07 [error] 15900#0: *178 upstream timed out (110: Connection timed out) while reading response header from upstream, client: 11.11.11.11, server: www.aaa.com, request: "GET /favicon.ico HTTP/1.1", upstream: "fastcgi://127.0.0.1:8999", host: "www.aaa.com"
--Manish