I want to use the Nginx sub_filter module and I want to except some files to substitute. Is there a good and clean solution for that? For example, I want to replace str_1 to str_2 in all javascripts, but not those that have some property like location, name, or even size.


1 Answer 1


When you use sub_filter_types it is added on top text/html, so pay attention for that. (So text/html is always replaced)

This is why you should use the sub_filter directive in different contexts of location block.

I do not know a way to instruct Nginx to sub_filter based on file size.

Remember that Nginx will replace the string in the current buffer, flush this buffer, and continue to the next buffer.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .