search

Home  >  Q&A  >  body text

nginx reverse proxy exclude directory

The two servers A and B use nginx reverse proxy to balance the load

A server's website abc.com is reverse-proxyed to Server B. The content of abc.com is provided by Server B. Domain name resolution and telecommunications lines are resolved to Server B, which is the origin site, and other lines are resolved to Server A.

Considering that server A still has remaining resources, transfer some of the static resources of server B to server A, and create a new folder file. That is, when accessing server abc.com/file of server A, the content will no longer be provided by server B, but by server B. Directly read the local content of server A. Because the entire site has been used as a reverse proxy before, so when testing server A abc.com/file/xxx.jpg, etc., it still reads the content of server B. If it does not, it will still report an error 404.

Solution: How to exclude the local file directory of server A when using reverse proxy?

怪我咯怪我咯2778 days ago875

reply all(1)I'll reply

  • 伊谢尔伦

    伊谢尔伦2017-05-16 17:12:06

    server {
        server_name abc.com;
        
        location /file {
            root /path/to/file/on/ServerA;
        }
        
        location / {
            proxy_pass http://ServerB;
        }
    }

    reply
    0
  • Cancelreply