How to redirect to specific upstream servers based on request URL in Nginx?

后端 未结 2 1816
小蘑菇
小蘑菇 2021-02-07 06:25

I\'m using Nginx as a load balancer for my 5 app servers.

I\'d like to redirect to specific servers based on the request URL, for instance:

acme.com/cate         


        
2条回答
  •  遥遥无期
    2021-02-07 06:38

    You will also need to rewrite the URL otherwise /whatever/ will get forwarded to the backend server

    location /admin/ {
        rewrite ^/admin^/ /$1 break;
        proxy_pass http://10.128.1.2;
    }
    

提交回复
热议问题