Welcome! Log In Create A New Profile

Advanced

sub_filter not working on JSON file

Posted by Friscia, Michael 
Friscia, Michael
sub_filter not working on JSON file
August 02, 2018 03:50PM
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?

___________________________________________
Michael Friscia
Office of Communications
Yale School of Medicine
(203) 737-7932 - office
(203) 931-5381 - mobile
http://web.yale.eduhttp://web.yale.edu/

_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Dmitry Volyntsev
Re: sub_filter not working on JSON file
August 02, 2018 04:00PM
On 02.08.2018 16:46, 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?
>

Hi,

Do not forget to configure sub_filter_types appropriately.



> ___________________________________________
>
> Michael Friscia
>
> Office of Communications
>
> Yale School of Medicine
>
> (203) 737-7932 - office
>
> (203) 931-5381 - mobile
>
> http://web.yale.edu http://web.yale.edu/
>
>
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> http://mailman.nginx.org/mailman/listinfo/nginx
>
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Friscia, Michael
Re: sub_filter not working on JSON file
August 02, 2018 04:20PM
Yeah, the sub_filter_types is fine, if I set it correctly it does not work. So I tested by using
Sub_filter_types *;
This works fine which makes me wonder what Nginx is seeing as the mime type of this json file. I'll dig through the upstream variables again but I don't recall seeing it unless it's right in front of my face and I'm being blind to it.

___________________________________________
Michael Friscia
Office of Communications
Yale School of Medicine
(203) 737-7932 - office
(203) 931-5381 - mobile
http://web.yale.edu http://web.yale.edu/


On 8/2/18, 9:49 AM, "Dmitry Volyntsev" <[email protected]> wrote:



On 02.08.2018 16:46, 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?
>

Hi,

Do not forget to configure sub_filter_types appropriately.



> ___________________________________________
>
> Michael Friscia
>
> Office of Communications
>
> Yale School of Medicine
>
> (203) 737-7932 - office
>
> (203) 931-5381 - mobile
>
> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fweb.yale.edu&amp;data=02%7C01%7Cmichael.friscia%40yale.edu%7Cbb4162e4f4dc4c2b17f308d5f87ed329%7Cdd8cbebb21394df8b4114e3e87abeb5c%7C0%7C0%7C636688145950069464&amp;sdata=Kam1ZbqWD8GXtkGJdvmR7M4sMheqYuPM5OSTEmw5RXE%3D&amp;reserved=0 https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fweb.yale.edu%2F&amp;data=02%7C01%7Cmichael.friscia%40yale.edu%7Cbb4162e4f4dc4c2b17f308d5f87ed329%7Cdd8cbebb21394df8b4114e3e87abeb5c%7C0%7C0%7C636688145950069464&amp;sdata=mfo%2FF4pMFLM3BTDQ6Xtm3ryesxM09Ci%2BYsv37TBbGCg%3D&amp;reserved=0
>
>
>
> _______________________________________________
> nginx mailing list
> nginx@nginx.org
> https://na01.safelinks.protection.outlook.com/?url=http%3A%2F%2Fmailman.nginx.org%2Fmailman%2Flistinfo%2Fnginx&amp;data=02%7C01%7Cmichael.friscia%40yale.edu%7Cbb4162e4f4dc4c2b17f308d5f87ed329%7Cdd8cbebb21394df8b4114e3e87abeb5c%7C0%7C0%7C636688145950079469&amp;sdata=93k%2BaN0xhqYb9BqOhE4kCwKbAjue2L2Fb%2FwAg0krldI%3D&amp;reserved=0
>


_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Maxim Dounin
Re: sub_filter not working on JSON file
August 02, 2018 05:20PM
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/
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Sorry, only registered users may post in this forum.

Click here to login