我需要基于文件扩展名和查询stringproxy_pass静态资产(.js .css)。
例如:
domain.com/foo.css – 转到upstream1 domain.com/foo.css?V=1234 – 转到upstream2
原因是我有一个3服务器设置 – 路由器,应用程序服务器和静态服务器。 我想任何请求干净的urldomain.com/foo.cs去上游1(我的静态服务器configuration)。 以及任何具有查询stringurl domain.com/foo.css?V=1234的请求转到upstream2(我的应用程序服务器被configuration)。
也许可以使用http://wiki.nginx.org/HttpLuaModule完成?
谢谢!
使用地图 。
map $arg_v $node { default upstream1; "~^[0-9]+$" upstream2; } server { listen 80; server_name domain.com; location ~ \.(css|js)$ { proxy_pass http://$node; } }