manoj janardhan
manoj janardhan

Reputation: 51

Nginx redirection - how to disable redirection for a particular URL?

We have set up nGinx redirection on 3 nodes, node1, node2, node3. Everything is working fine now. We have one small requirement. We need one particular URL to load from only one server. Is it possible by tweaking this configuration.

I will paste our present configuration of node1 here.

  upstream project.in {
    server node2:8080 weight=10 max_fails=3 fail_timeout=30s;
    server node3:8080 weight=10 max_fails=3 fail_timeout=30s;
  }

  server {
    listen 80;
    server_name www.example.in;
    location / {
      proxy_pass http://example.in;
    }
  }

According to the above configuration, what ever traffic which comes to node1 will get shared between node2 and node3. Our requirement if somebody access http://example.in/test/administrator/ it should go only to node1. In other words we need to disable load balancing for this particular URL. Is this possible by tweaking the configuration file?

Upvotes: 0

Views: 834

Answers (1)

CyberDem0n
CyberDem0n

Reputation: 15046

You should add another location section with overriden proxy_pass

location / {
    proxy_pass http://project.in; # your upstream name for load balancing
}

location /test/administration/ { # excluded location
    proxy_pass http://node1:8080; # goes to another backend
}

Upvotes: 5

Related Questions