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!
stream
is a top-level block statement and needs to be in your main Nginx configuration file. Thesites-enabled
directory is intended for configuration fragments that are included into thehttp
block. Usenginx -T
(uppercaseT
) to view the entire configuration across all included files. – Automat