sub_filter not working on JSON file

Maxim Dounin mdounin at mdounin.ru
Thu Aug 2 15:11:14 UTC 2018


Hello!

On Thu, Aug 02, 2018 at 01:46:35PM +0000, Friscia, Michael wrote:

> I’m trying to figure out why my sub_filter is not working on a 
> JSON file. I do have application/json and text/json listed in 
> the sub_filter_types but the simple string replace is not 
> happening. It causes me to think that for whatever reason, Nginx 
> is not seeing this file as JSON. Is there a way to output what 
> mime type the file from the upstream server is so I can make 
> sure I have the right filter type?
> 
> Or, is there something I should also be doing to make the 
> sub_filter work on a JSON file?

Some things to check, in no particular order:

- The Content-Type header as sent by the upstream server is 
  correct.  Check the response headers in your favorite client to 
  see the Content-Type header (you can also log 
  $sent_http_content_type or $upstream_http_content_type, but 
  usually checking response headers is enough).

- The Content-Type in question is listed in the sub_filter_types 
  directive.

- The response is not compressed by the upstream server.  If it 
  is, consider adding `proxy_set_header Accept-Encoding "";` to 
  the configuration.

-- 
Maxim Dounin
http://mdounin.ru/


More information about the nginx mailing list