Welcome! Log In Create A New Profile

Advanced

sub_filter (CSS,JS)

Posted by Adrian Acosta 
Adrian Acosta
sub_filter (CSS,JS)
April 12, 2018 09:00AM
Hi Everyone!

We're using nginx as a reverse proxy for a staging system so customers can
view the contents of their directories without a resolving domain.

It's working really well, but the issue is, references to their domain
aren't being filtered inside their CSS or JS files which are also loading
via the proxy URL.

*Currently the configuration of each host is as follows. *

server {
server_name example-com-au.tempexample.com.au;
location / {
proxy_set_header Host real-domain.com;
add_header X-Robots-Tag "noindex, nofollow, nosnippet, noarchive";
proxy_pass http://ip.ip.ip.ip/;
sub_filter_types text/html text/css text/javascript;
proxy_set_header Accept-Encoding "*";
sub_filter "http://real-domain.com/"; "
http://example-com-au.tempexample.com.au/";;
sub_filter_once off;
}
}


Does anybody know if we can further configure a sub_filter so that the
contents of JS and CSS files are also filtered when loaded via the proxy?

It has been very hard finding relevant information, the docs aren't overly
helpful and even stackoverflow hasn't wielded good results.

Thanks in advance!
_______________________________________________
nginx mailing list
nginx@nginx.org
http://mailman.nginx.org/mailman/listinfo/nginx
Reinis Rozitis
RE: sub_filter (CSS,JS)
April 12, 2018 09:40AM
> It's working really well, but the issue is, references to their domain aren't being filtered inside their CSS or JS files which are also loading via the proxy URL.

Typically it means that the response from the upstream comes compressed (gzipped) and sub_filter module doesn't handle that.


Try instead of:
> proxy_set_header Accept-Encoding "*";

setting it to empty:
proxy_set_header Accept-Encoding "";


rr

_______________________________________________
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