当前位置: > Linux服务器 > nginx >

nginx的反向代理和负载均衡的区别是什么

时间:2014-05-15 01:23来源:linux.it.net.cn 作者:IT网

最近在研究nginx的负载均衡和反向代理,先看下这两个简单的配置吧!

负载均衡

 

01 worker_processes 1;
02 events {
03    worker_connections 1024;
04 }
05 http{
06     upstream lxx {//默认是80端口
07         server 192.168.0.62 weight=2;
08         server 192.168.0.161 weight=3;
09     }
10     server {
11         listen 80;
12         location / {
13             proxy_pass http://lxx;
14         }
15     }
16 }

 

反向代理

01 worker_processes 1;
02 events {
03    worker_connections 1024;
04 }
05 http{
06     upstream lxx {//默认是80端口
07         server 192.168.0.62 weight=2;
08         server 192.168.0.161 weight=3;
09     }
10     server {
11         listen 80;
12         location / {
13             proxy_pass http://lxx;
14              
15  
16             #Proxy Settings
17             proxy_redirect     off;
18             proxy_set_header   Host             $host;
19             proxy_set_header   X-Real-IP        $remote_addr;
20             proxy_set_header   X-Forwarded-For  $proxy_add_x_forwarded_for;
21             proxy_next_upstream error timeout invalid_header http_500 http_502 http_503 http_504;
22             proxy_max_temp_file_size 0;
23             proxy_connect_timeout      90;
24             proxy_send_timeout         90;
25             proxy_read_timeout         90;
26             proxy_buffer_size          4k;
27             proxy_buffers              4 32k;
28             proxy_busy_buffers_size    64k;
29             proxy_temp_file_write_size 64k;
30         }
31     }
32 }

 

从配置上来看,它只是多了Proxy Settings下面的一些设置参数!但从实际的表现结果来看,感觉区别并不是很大,负载均衡已经可以把用户的请求按照相关算法和规则发送到web集群的某台机器,而反向代理也是实现了如此的功能,它们的具体的区别在哪里?求普及!

 
 
(责任编辑:IT)
------分隔线----------------------------
栏目列表
推荐内容