Nginx 负载均衡 设置
2015-11-18 14:32
633 查看
Nginx做代理服务器,实现负载均衡配置:
nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 10000;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
#设置被负载均衡的服务器路径 weight权重
upstream site {
server 127.0.0.1:80 weight=2;
server 127.0.0.1:8080 weight=2;
#server 192.168.100.4:8091 weight=2;
}
server {
listen 8079;
server_name localhost;
location / {
proxy_pass http://site; # 代理
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
nginx.conf
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 10000;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
#设置被负载均衡的服务器路径 weight权重
upstream site {
server 127.0.0.1:80 weight=2;
server 127.0.0.1:8080 weight=2;
#server 192.168.100.4:8091 weight=2;
}
server {
listen 8079;
server_name localhost;
location / {
proxy_pass http://site; # 代理
root html;
index index.html index.htm;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
相关文章推荐
- nginx代理指定目录
- 访问Nginx发生SSL connection error的一种情况
- Nginx+Naxsi部署专业级Web应用防火墙
- CentOS 6.2实战部署Nginx+MySQL+PHP
- nginx中http核心模块的配置指令2
- nginx中http核心模块的配置指令3
- nginx中http核心模块的配置指令4
- nginx中http的fastcgi模块的配置指令1
- 负载均衡技术沙龙1期(关于咱的图片)
- 负载均衡沙龙活动第二期现场问答汇集
- Nginx 学习笔记(一)
- 流量引导:网络世界的负载均衡解密
- 流量引导:网络世界的负载均衡解密
- 网站502与504错误分析
- 艰难完成 nginx + puma 部署 rails 4的详细记录
- 把Lua编译进nginx步骤方法
- 浅谈sqlserver的负载均衡问题
- web 应用中常用的各种 cache详解
- Linux系统上配置Nginx+Ruby on Rails+MySQL超攻略