Tem a certeza que o seu ficheiro ".js" tem tipo mime "text / html"?
syntax: sub_filter_types mime-type ...;
default: sub_filter_types text/html;
context: http, server, location
Enables string replacement in responses with the specified MIME types in addition to “text/html”. The special value “*” matches any MIME type (0.8.29).
@ link