Welcome! Log In Create A New Profile

Advanced

nginx load balancer config? - help! :)

Posted by tdenad 
nginx load balancer config? - help! :)
January 08, 2016 04:10AM
Hi! I'm new to NGINX and I would like to setup a load balancer for our web server. this is what my /etc/nginx/sites-available/default looks like

upstream server {
server 192.168.1.101;
server 192.168.1.102;
}
server {
listen 80;
location / {
proxy_set_header X*Forwarded*For $proxy_add_x_forwarded_for;
proxy_pass http://server;
}
}

but if i run (nginx -t), i get this error -

nginx: [emerg] unknown directive "upstream server" in /etc/nginx/sites-enabled/default:1
nginx: configuration file /etc/nginx/nginx.conf test failed

searched the internet and they fix this kind of issue by adding it to the http {} or adding this line in the nginx.conf file - include /etc/nginx/sites-enabled/*;
I have tried several solution found on the internet and still got this error. I even created a new VM for a fresh setup, still the same. BTW, i was following this example - https://www.youtube.com/watch?v=SpL_hJNUNEI

Inputs will be greatly appreciated. Thank you!
Sorry, only registered users may post in this forum.

Click here to login

Online Users

Guests: 186
Record Number of Users: 8 on April 13, 2023
Record Number of Guests: 421 on December 02, 2018
Powered by nginx      Powered by FreeBSD      PHP Powered      Powered by MariaDB      ipv6 ready