0

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?

1

About first part of your question:

Update your regular expression. I think you don't need parenthesis in case you have only one extension:

location ~* ^.+\.js$ {
proxy_pass http://127.0.0.1:8188/filter?source=$1;
proxy_redirect off;
proxy_buffering off;
}
| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.