search

Home  >  Q&A  >  body text

Load Balancing - How to invert the location of nginx (jump except for some links)

Requirements: Except /v1/updload, /v1/uinfo, /v1/auth, all requests except these three URIs are forwarded Go to another server for processing.

First paste a piece of code in the nginx config configuration file server:

location ~* ^/v1/(?![upload|uinfo|auth])$ {
    proxy_pass http://other.domain.com;
}

I did it based on the information on the Internet, but I tried it and it didn’t meet the requirement. I don’t know if it’s because I understood something wrong and didn’t do it right, or it’s not feasible in the first place. And because it contains part of the post request, I didn’t use if rewrite. way to deal with it. So, I would like to ask, is there any way to achieve this? Could anyone who knows please give me some advice? Thank you!

巴扎黑巴扎黑2740 days ago1562

reply all(1)I'll reply

  • 巴扎黑

    巴扎黑2017-05-27 17:47:03

    location ~ ^\/v1\/(upload|uinfo|auth)$ {
        proxy_pass 你自己的网址;
    }
    
    location / {
        proxy_pass http://other.domain.com;
    }

    reply
    0
  • Cancelreply