我想将所有请求重定向到特定服务器,例如:
/f - 重定向到本地主机:8001
/c - 重定向到 localhost:8000
/c/test - 重定向到 localhost:8000/test
我尝试了这段代码,但是对任何 url nginx 的所有请求都将重定向到 /c 并且代理传递给 localhost:8000
server {
listen 80;
server_name localhost;
location /f {
proxy_pass http://localhost:8001/;
}
location /c {
proxy_pass http://localhost:8000/;
}
location / {
return 301 /c;
}
}