Reverse Proxy to filter out js files from multiple hosts in nginx
Posted
by
stwissel
on Server Fault
See other posts from Server Fault
or by stwissel
Published on 2014-08-21T09:21:34Z
Indexed on
2014/08/21
10:21 UTC
Read the original article
Hit count: 216
nginx
|reverse-proxy
I have a website http://someplace.acme.com that I want my users to access via http://myplace.mycorp.com - pretty standard reverse proxy setup.
The special requirement: any js file - either identified by the .js extension and/or the mime-type (if that is possible) text/javascript needs to be served from a different location, a local tool that inspects the js for potential threats.
So I have
location / {
proxy_pass http://someplace.acme.com;
proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
proxy_redirect off;
proxy_buffering off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
location ~* \.(js)$ {
proxy_pass http://127.0.0.1:8188/filter?source=$1;
proxy_redirect off;
proxy_buffering off;
}
The JS still is served from remote and I have no idea how to check for the mime type. What do I miss?
© Server Fault or respective owner