Turn off gzip for a location in Nginx
I'd suppose that URLs you're requesting are being handled with try_files
inside location ^~ /foo/
and due to absence of those files, they're internally re-directed to another location
handler not having gzip off
inherited.
Try using "named location" in /foo
location, and then define that "named" location @fooNoGzip
with gzip off
inside and fascgi_pass
stuff.