2

i'm try to setup load balancer with nginx to keep Client IP at backends node by create file /etc/nginx/sites-available/test.conf and symlink for it

stream {
    upstream backend_servers {
        server http://server1.com;
        server http://server2.com;
    }
    
    server {
        listen     80;
        proxy_set_header X-Forwarded-For $remote_addr;
        proxy_pass backend_servers;
    }
}

But when i run nginx -t to check, this error appear. can anyone tell me what to do now? Thanks!

manhkhoa168
  • 151
  • 1
  • 4
  • 8
  • 3
    `stream` is a top-level block statement and needs to be in your main Nginx configuration file. The `sites-enabled` directory is intended for configuration fragments that are included into the `http` block. Use `nginx -T` (uppercase `T`) to view the entire configuration across all included files. – Richard Smith Sep 29 '21 at 10:06
  • @manhkhoa168 See more detailed explanation [here](https://stackoverflow.com/a/69221414/7121513). – Ivan Shatsky Sep 29 '21 at 10:24

0 Answers0