#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream nodes {
server localhost:8080 weight=1;
server localhost:8081 weight=1;
}
server {
listen 80;
server_name localhost;
location / {
proxy_pass http://nodes;
proxy_redirect default;
}
# error_page 500 502 503 504 /50x.html;
# location = /50x.html {
# root html;
# }
}
}
nodes是节点服务器地址,proxy_pass http://nodes;指向结点服务器,权重weight设置一样就是把流量平均分配到各个节点服务器上
请求方式:localhost/