replace-filter-nginx-module icon indicating copy to clipboard operation
replace-filter-nginx-module copied to clipboard

types setting not working

Open gumpjt opened this issue 8 years ago • 5 comments

Hi there, I add this in my config, but when the response is text/html, it will also replace. Any comments?

replace_filter_types application/x-javascript javascript text/javascript application/javascript;

Thanks.

gumpjt avatar Jun 03 '17 01:06 gumpjt

@gumpjt This indeed looks like a problem in the implementation of the replace_filter_types directive. Will you mind creating a pull request to address this issue? Many thanks!

agentzh avatar Jun 03 '17 17:06 agentzh

@agentzh I'm a newbie of C and Nginx. I'm willing to but I think it's out of my hand... 😭 I checked my config and I'm sure there is something wrong there.

gumpjt avatar Jun 04 '17 03:06 gumpjt

@gumpjt One workaround is to use ngx_lua's header_filter_by_lua* to conditionally set a custom nginx variable, say, $skip_replace, and then reference that variable in the replace_filter_skip directive:

https://github.com/openresty/replace-filter-nginx-module#replace_filter_skip

agentzh avatar Jun 04 '17 19:06 agentzh

@agentzh Thanks.

I also found this method and I'm struggling about the order of header_filiter_by_lua* and the replace_filter_skip directive. Now I need to make sure that header_filter_by_lua* should run before replace_filter_skip directive.

I'm using openresty, is there any way to change it? If I use pure Nginx, I can make the config options like this:

./configure --add-module=replace_module
--add-module=lua_nginx_module

Then the header_filter will handle first. But how to do it with openresty?

gumpjt avatar Jun 05 '17 08:06 gumpjt

@gumpjt Hmm, seems like we should add a new --prepend-module=PATH option to OpenResty's ./configure script so that the modules can be prepended to OpenResty's own --add-module=PATH options. Will you contribute a patch for this? Thanks!

agentzh avatar Jun 05 '17 18:06 agentzh