worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
upstream bbs_server_pools { # bbs业务服务器池
server 10.0.0.101:80 weight=1;
server 10.0.0.102:80 weight=1;
# 假设10.0.0.101和10.0.0.102为bbs业务的两个集群节点
}
upstream blog_server_pools { # blog业务服务器池
server 10.0.0.103:80 weight=1;
server 10.0.0.104:80 weight=1;
# 假设10.0.0.103和10.0.0.104为bbs业务的两个集群节点
}
server {
listen 10.0.0.12:80;
server_name bbs.linuxidc.com;
location / {
proxy_pass ;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
}
server {
listen 10.0.0.13:80;
server_name blog.linuxidc.com;
location / {
proxy_pass ;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header Host $host;
}
}
}
可以看到,两台负载均衡器的Nginx配置是一样的。
CentOS 7下Keepalived + HAProxy 搭建配置详解