nginxでロードバランシングの設定サンプル

1.システム要件:
システム負荷ロードバランシングサーバ(PA)
www.mydomain.com(Global network)
192.168.2.20(Private network)

Webサーバー1(P1)
192.168.2.30(Pravite)

Webサーバー2(P2)
192.168.2.40(Private)

Webサーバー3(P3)
192.168.2.50(Private)

2.nginx.confの設定
PA
upstream startnews24.mydomain.com {
server 192.168.2.30:8080;
server 192.168.2.40:8081;
server 192.168.2.50:8082;
}

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

P1のnginx.conf
server{
listen 8080;
server_name www.mydomain.com;
index index.html;
root /data/htdocs/www;
}

P2のnginx,.conf

server{
listen 8081;
server_name www.mydomain.com;
index index.html;
root /data/htdocs/www;
}

P3のnginx.conf
server{
listen 8082;
server_name www.mydomain.com;
index index.html;
root /data/htdocs/www;
}

Nginx

Posted by arkgame