Answer the question
In order to leave comments, you need to log in
NGINX: how to serve a remote file with "native" headers, changing its contents on the fly?
Good day.
There is a location for a text/javascript file (http(s)://mydomain.com/file.js), the file itself must be taken from a link to an external resource (http(s)://somedomain.com/file.js).
It is necessary to return the file http(s)://somedomain.com/file.js when requesting http(s)://mydomain.com/file.js , changing the content on the go (replacing one address with another in several places) and substituting the headers of the remote file.
Is a subject possible, and if so, how? And if not, how can you achieve what you want (give away a remote file (tightened by curl? ..), changing headers and contents on the fly)?
Answer the question
In order to leave comments, you need to log in
maybe a working example?
my version doesn't work ( images is not replaced with images/block )
server {
listen 80;
server_name mydomain.com;
location /file.js {
proxy_pass http://somedomain.com;
proxy_set_header Accept-Encoding "";
sub_filter 'images' 'images/block';
sub_filter_once off;
sub_filter_types *;
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question