Home > Back-end >  Nginx load balancing doesn't work on location path
Nginx load balancing doesn't work on location path

Time:01-25

The load balancer configuration /etc/nginx/conf.d/load-balancer.conf is:

upstream myproject {
  ip_hash;
  server 127.0.0.1:81;
}

upstream myproject2 {
  ip_hash;
  server 127.0.0.1:82;
}

server {
  listen 80;

  location / {
    proxy_pass http://myproject;
  }

  location /b {
    proxy_pass http://myproject2;
  }
}

The url

localhost

is working, but the url

localhost/b

is not working and there is the error message

404 Not Found

in the web browser.

What could be problem?

The url

localhost:82

is working.

Note: The situation is simplified. Later I will add more urls etc.

CodePudding user response:

This was because the url

localhost:82/b

wasn't working. When I got it working, I fixed the problem.

  •  Tags:  
  • Related