Nginx Load Balancing
2016-01-11 10:52
603 查看
Nginx 简单的负载均衡配置示例:
或
参考链接: Simple Load Balancing & Logging Settings
/etc/nginx/nginx.conf:
http { ... upstream myproject { server 127.0.0.1:8000 weight=3; server 127.0.0.1:8001; server 127.0.0.1:8002; server 127.0.0.1:8003; } server { listen 80; server_name www.domain.com; location / { proxy_pass http://myproject; } } ## # Logging Settings ## log_format access '$remote_addr - $remote_user [$time_local] ' '"$request" $status $body_bytes_sent ' ' $request_time $upstream_response_time'; access_log /var/log/nginx/access.log access; error_log /var/log/nginx/error.log; ... }
/etc/hosts:
127.0.0.1 localhost 127.0.1.1 user-3010 # myproject 127.0.0.1 www.domain.com
或
/etc/nginx/nginx.conf:
http { ... upstream myproject { server 127.0.0.1:8000 weight=3; server 127.0.0.1:8001; server 127.0.0.1:8002; server 127.0.0.1:8003; } server { listen 80; server_name self_machine_ip_address; location / { proxy_pass http://myproject; } ... }
/var/log/nginx/access.log:
192.168.222.9 - - [11/Jan/2016:16:09:47 +0800] "GET /myproject/users HTTP/1.1" 200 12964 0.010 0.001, 0.009
参考链接: Simple Load Balancing & Logging Settings
相关文章推荐
- FastDFS+nginx---(二)安装配置测试
- nginx php 安装
- nginx 支持 codeigniter 的path info
- Fastdfs+nginx---(一) 安装前准备
- Nginx中的用户认证配置及阻止用户使用代理访问的方法
- nginx服务器安装及配置文件详解
- Nginx配置upstream实现负载均衡
- Nginx 服务器的搭建
- nginx将日志通过rsyslog保存
- nginx架构总结--nginx源码系列(一)
- 使用gdb调试Nginx worker进程
- ubuntu下安装及使用nginx
- Ubuntu下安装Nginx详细步骤
- Mac OS X安装Nginx
- 架构之路:nginx与IIS服务器搭建集群实现负载均衡(二)
- LNMP架构搭建(Linux+Nginx+MySQL+PHP)
- Nginx编译安装时常见错误分析
- phpstudy搭建nginx+php服务器显示php网页
- nginx开机自启动
- Nginx-start