//默认动态,静态直接找设置的static,上传找upload
upstream static_pools { server 10.0.0.9:80 weight=1; } upstream upload_pools { server 10.0.0.10:80 weight=1; } upstream default_pools { server 10.0.0.9:8080 weight=1; }server { listen 80; server_name www.xuliangwei.com;
url:
location / { proxy_pass http://default_pools; include proxy.conf;}
url:
location /static/ { proxy_pass http://static_pools; include proxy.conf;}
url:
location /upload/ { proxy_pass http://upload_pools; include proxy.conf;}
}
//方案2:以if语句实现。
if ($request_uri ~* "^/static/(.)$") { proxy_pass ; } if ($request_uri ~ "^/upload/(.*)$") { proxy_pass ; } location / { proxy_pass ; include proxy.conf; }