NGINX Proxy pass,全部重定向到一条路由

问题描述 投票:0回答:0

我想将所有请求重定向到特定服务器,例如:

/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;
   }
}
nginx nginx-reverse-proxy nginx-config nginx-location
© www.soinside.com 2019 - 2024. All rights reserved.