Nginx负载均衡配置
2015-11-06 23:06
537 查看
场景描述
单机缺点
当量上来后由于单机请求压力大,存在单点故障等问题负载优点
降低单点故障提高服务器处理能力
灵活控制请求流量
隐藏真实服务器地址
负载均衡
如下图
Nginx配置
配置如下
#user nobody; worker_processes 8; worker_rlimit_nofile 65535; events { use epoll; worker_connections 8192; } #http核心 http { include mime.types; default_type application/octet-stream; client_max_body_size 10M; client_body_buffer_size 256k; #日志格式 log_format main '$remote_addr - $remote_user [$time_local] "$request" ' '"$status" $body_bytes_sent "$http_referer" ' '"$http_user_agent" "$http_x_forwarded_for" ' '"$gzip_ratio" $request_time $bytes_sent $request_length'; access_log logs/access.log main; sendfile on; keepalive_timeout 65; upstream backend{ server 192.168.1.1 weight=1; server 192.168.1.1 weight=1; } #虚拟服务器 server { listen 80; server_name www.go008.com; location / { root html; index index.html index.htm; proxy_pass http://backend; proxy_redirect off; proxy_set_header Host $http_host; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Cookie $http_cookie; chunked_transfer_encoding off; proxy_pass_header Set-Cookie; } #error_page 404 /404.html; error_page 500 502 503 504 /50x.html; location = /50x.html { root html; } } }
白话描述
当用户请求www.go008.com的时候,由于该域名IP地址解析到负载均衡nginx所在服务器由于虚拟服务器server配置了监听www.go008.com:80
请求被分发到proxy_pass配置的反向代理模块backend
upstream根据配置将请求分发到后端真实服务器
相关文章推荐
- centos 6.6下安装nginx
- Nginx1.8.0 编译安装
- Keeplived配置Nginx双机高可用
- nginx [warn]: conflicting server name on 0.0.0.0:80 ignored
- nginx封锁恶意IP,并且定时取消的两种脚本
- nginx封锁恶意IP,并且定时取消的两种脚本
- python web 部署:nginx + gunicorn + supervisor + flask
- Nginx下搭建Nagios
- Nginx中的rewrite指令(break,last,redirect,permanent)
- Nginx缩略图和Fastdfs整合以及image_filter配置,7点经验结论和5个参考资料
- Nginx缩略图和Fastdfs整合以及image_filter配置,7点经验结论和5个参考资料
- Nginx缩略图和Fastdfs整合以及image_filter配置,7点经验结论和5个参考资料
- nginx url转发的一种方式
- Nginx平滑升级的详细操作方法
- keepalived + nginx HA 配置
- nginx多进程模型之热代码平滑升级
- nginx 监听多个端口 80和81
- Nginx的负载均衡方案详解
- Apache和Nginx防盗链的几种配置方法
- Node.js 配置Nginx