nginx负载均衡与反向代理,配置内容如下:
1,设置在http段:
复制代码代码示例:
upstream my_server_pool {
server 192.168.10.21:80 weight=1 max_fails=2 fail_timeout=30s; server 192.168.10.20:80 weight=1 max_fails=2 fail_timeout=30s; proxy_cache_path /usr/local/nginx/proxy_temp levels=1:2 keys_zone=cache_one:500m inactive=1d max_size=1g;
2,设置在server段:
复制代码代码示例:
location /sms {
(责任编辑:IT)proxy_pass http://my_server_pool; proxy_set_header Host $host; proxy_cache cache_one; proxy_set_header X-Forwarded-For $remote_addr; proxy_cache_valid 200 10m; proxy_cache_valid 304 1m; proxy_cache_valid 301 302 1h; proxy_cache_valid any 1m; proxy_cache_key $host$uri$is_args$args; } |