Nginx负载均衡配置实例

www.olinux.org.cn域名指向 Nginx 所在的服务器IP。

用户访问http://www.olinux.org.cn,将其负载均衡到192.168.1.2:80、192.168.1.3:80、192.168.1.4:80、192.168.1.5:80四台服务器。

用户访问http://www.arezone.cn,将其负载均衡到192.168.1.7服务器的8080、8081、8082端口。

以下为配置文件nginx.conf:

user www www;
worker_processes 10;
worker_rlimit_nofile 51200;
events
{
worker_connections 51200;
}

http
{
upstream www.olinux.org.cn {
server 192.168.1.2:80;
server 192.168.1.3:80;
server 192.168.1.4:80;
server 192.168.1.5:80;
}

upstream www.arezone.cn {
server 192.168.1.7:8080;
server 192.168.1.7:8081;
server 192.168.1.7:8082;
}

server
{
listen 80;
server_name www.olinux.org.cn;
location / {
proxy_pass http://www.olinux.org.cn;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}

log_format www_olinux_org_cn ‘$remote_addr – $remote_user [$time_local] $request ‘
‘”$status” $body_bytes_sent “$http_referer” ‘
‘”$http_user_agent” “$http_x_forwarded_for”‘;
access_log /var/log/httpd/olinux.log www_olinux_org_cn;
}

 server
{
listen 80;
server_name www.arezone.cn;
location / {
proxy_pass http://www.arezone.cn;
}
access_log /var/log/httpd/arezone.log;
}
}

够简单吧!

您可以选择一种方式赞助本站

支付宝转账赞助

支付宝扫一扫赞助

发表评论

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

图片 表情