1. round-robin (default)
upstream localapp {
server 127.0.0.1:8080 weight=2; (다른 서버보다 2배 요청을 더 받음)
server 127.0.0.1:8081;
server 127.0.0.1:8082;
}
server {
listen 80;
server_name load.test.co.kr;
access_log /var/log/nginx/load-access.log combined;
location / {
proxy_pass http://localapp;
}
}
2. least connetion
upstream localapp {
least_conn;
server 127.0.0.1:8080;
server 127.0.0.1:8081;
server 127.0.0.1:8082;
}
server {
listen 80;
server_name load.test.co.kr;
access_log /var/log/nginx/load-access.log combined;
location / {
proxy_pass http://localapp;
}
}
3. hash
upstream localapp {
hash $remote_addr consistent; (ip_hash 사용시 10.10.10.xxx c class만 사용하여 hash)
server 127.0.0.1:8080;
server 127.0.0.1:8081;
server 127.0.0.1:8082;
}
server {
listen 80;
server_name load.test.co.kr;
access_log /var/log/nginx/load-access.log combined;
location / {
proxy_pass http://localapp;
}
}
4. 추가
add_header upstream-addr $upstream_addr;
add_header upstream-connect-time $upstream_connect_time;
'오픈소스 > nginx' 카테고리의 다른 글
nginx 인증 (0) | 2018.02.06 |
---|---|
nginx tcp/application load balancing (0) | 2018.02.05 |
nginx 접속 제한 (rate limiting) (0) | 2018.02.05 |
nginx cache (0) | 2018.02.05 |
nginx proxy setup (0) | 2018.02.05 |