How to force nginx do return 204 and log it into access log?

Hi,

I’m trying to implement logic which apache making return status 204
instead of 200 and log it into access log.
It doing “RedirectMatch 204 xxxxx.gif$”
for nginx I have created this part of config which working very close to
above:

        if ( $request_uri ~ xxxxx.gif ) {
              return 204;
        }
        location ~ xxxx.gif {
            log_format special-v4 "$msec\t$args\t$http_cookie";
            access_log /path/to/access.log special-v4;
            empty_gif;
            internal;
        }

so it works but not writing into log.

Next one writing into log but not giving response 204:
        location ~ xxxx.gif {
            log_format special-v4 "$msec\t$args\t$http_cookie";
            access_log /path/to/access.log special-v4;
            empty_gif;
            internal;
            return 204;
        }

My question: is it possible to have ability write access log and have
retcode 204 without binary modification custom modules?

Posted at Nginx Forum: