十二、负载均衡
1、nginx负载均衡基础知识
nginx的upstream目前支持四种方式的分配
简单的负载无衡实例:
vi nginx.conf
......
#loadblance my.linuxtone.org
upstream my.linuxtone.org {
ip_hash;
server 127.0.0.1:8080;
server 192.168.169.136:8080;
server 127.0.0.1:8080;
server 127.0.0.1:8080;
server 127.0.0.1:8080;
server 127.0.0.1:8080;
}
.............................
include vhosts/linuxtone_lb.conf
.............................
#vi proxy.conf
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X_Real_IP $remote_addr;
proxy_set_header X_Forwarded-For $proxy_add_x_forwardr_for;
client_max_body_size 50m;
client_body_buffer_size 256k;
proxy_connect_timeout 30;
proxy_send_timeout 30;
proxy_read_timeout 60;
proxy_buffer_size 4k;
proxy_buffers 432k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
proxy_max_temp_file_size 128m;
proxy_store on;
proxy_store_access user:rw group:rw all:r;
#nginx cache
#client_body_temp_path /data/nginx_cache/client_body 1 2;
proxy_temp_path /data/nginx_cache/proxy_temp 1 2;
#vi linuxtone_lb.conf
server{
listen 80;
server_name my.linuxtone.org;
index index.php;
root /data/www/wwwroot/mylinuxone;
if(-f $request_filename){
break;
}
if(-f $request_filename/index.php){
rewrite(.*)$1/index.php break;
}
error_page 403
location /{
if(!-e $request_filename){
proxy_pass
break;
}
include /usr/local/nginx/conf/proxy.conf;
}
}
更多想要了解nginx的资料可以上网:http://31543.blog.51cto.com/attachment/200902/21543_1233566448.pdf
查询一下的!
阅读(612) | 评论(0) | 转发(0) |