当前位置:首页 > 服务器技术 > nginx

nginx 负载均衡实现

nginx的配置内容 是用了lnmp 环境,在此基础上的修改

 

 开启了两个服务器,

192.168.56.102:8080

192.168.56.1:81

 

# 添加服务器列表,真实对应的服务器都在下面
# weight 权重,数字越大,被分配的可能性越高
#
upstream new_pool { server 192.168.56.102:8080 weight=4 max_fails=2 fail_timeout=30s; server 192.168.56.1:81 weight=4 max_fails=2 fail_timeout=30s; } server { listen 80; server_name www.new.com ; location / { proxy_pass http://new_pool; proxy_set_header Host $host; proxy_set_header X-Real-IP $remote_addr; } include rewrite/none.conf; include enable-php.conf; location ~ .*.(gif|jpg|jpeg|png|bmp|swf)$ { proxy_pass http://new_pool; # 图片代理 expires 30d; } location ~ .*.(js|css)?$ { proxy_pass http://new_pool; # js/css 代理 expires 12h; } location ~ /.well-known { allow all; } location ~ /. { deny all; } access_log off; }

 

 

 本文参考:https://www.cnblogs.com/youzhibing/p/7327342.html


【说明】本文章由站长整理发布,文章内容不代表本站观点,如文中有侵权行为,请与本站客服联系(QQ:254677821)!