我想用nginx配置一个反向代理,配置文件如下:
worker_processes 1;
worker_rlimit_nofile 65535;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream webpool1{
server 192.168.43.39:8081;
}
upstream webpool2{
server 192.168.43.4:8081;
}
server {
listen 80;
server_name localhost;
location /find {
if ($arg_userId ="123"){
proxy_pass http://webpool1;
}
if ($arg_userId = "1"){
proxy_pass http://webpool2;
}
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
我希望在地址栏输入 localhost/find?userId=123 的时候能跳转到192.168.43.39去,
输入 localhost/find?userId=1 的时候能跳转到192.168.43.4去。其中192.168.43.39是localhost。
但是我在试验的时候,不管userId传的是1还是123,最后的地址都是localhost
请各位大神看看是什么问题,帮忙解决一下