nginx 反向代理 和lvs负载均衡
2016-11-09 11:47
176 查看
nginx反向代理:用户请求nginx代理服务器然后代理服务器将用户请求转为服务器再由nginx代理服务器将服务器的响应反应给用户。
lvs负载均衡:用户请求nginx代理服务器然后代理服务器将用户请求转为服务器再由服务器直接响应用户的请求
nginx反向代理用的是
在http语块内定义:
upstream web_pools{
ip_hash;#wrr 默认是rr weight越大接受的请求越多 ip_hash会话保持 #第三方算法 url_hash web缓存 fair 根据后端rs 响应速度分配请求
server domainname|ip:port weight=2 max_fails=2 fail_timeout=20s#fail_timeout检测失败后多少时间后再次检测 ip_hash时weight无用
server domainname|ip:port backup;#高可用 ip_hash不支持
}
lvs负载均衡:用户请求nginx代理服务器然后代理服务器将用户请求转为服务器再由服务器直接响应用户的请求
nginx反向代理用的是
ngx_http_upstream_modulemodule is used to define groups of servers that can be referenced by the proxy_pass, fastcgi_pass, uwsgi_pass, scgi_pass, and memcached_pass directives.
在http语块内定义:
upstream web_pools{
ip_hash;#wrr 默认是rr weight越大接受的请求越多 ip_hash会话保持 #第三方算法 url_hash web缓存 fair 根据后端rs 响应速度分配请求
server domainname|ip:port weight=2 max_fails=2 fail_timeout=20s#fail_timeout检测失败后多少时间后再次检测 ip_hash时weight无用
server domainname|ip:port backup;#高可用 ip_hash不支持
}
location / { proxy_pass http://localhost:8000; proxy_set_header Host $host;#后端RS配置有多个虚拟主机时将用户请求的真实host反应给rs proxy_set_header X-Forwarded-For $remote_addr;#让后端RS服务器记录访问用户的真实IP apache web LogFormat "\"%{X-Forwarded-For}i\" %l %u %t \"%r\" %>s %b \"%{Referer}i\" \"%{User-Agent}i\"" combined nginx web 会自动记录真实IP }
相关文章推荐
- nginx 反向代理问题小结
- NginX反向代理服务器(Reverse Proxy)——【二】NginX配置文件修改
- Nginx反向代理缓存 + CND+PHP缓存 - 学习笔记
- 配置Nginx反向代理Tomcat
- nginx反向代理到tomcat,并在request中获取客户端请求ip
- nginx反向代理服务器端口问题
- 烂泥:使用UPUPW的Nginx进行反向代理及反向代理IIS
- squid,nginx,lighttpd反向代理的区别
- 使用nginx反向代理时,如何正确获取到用户的真实ip
- Nginx 反向代理、负载均衡、页面缓存、URL重写及读写分离详解
- nginx反向代理后获取不到客户端的真实ip地址
- nginx反向代理跨域基本配置与常见误区
- [置顶] Nginx 反向代理、负载均衡、虚拟主机实践教程
- 搭建nginx反向代理用做内网域名转发
- Nginx发布web和配置反向代理
- Nginx之反向代理
- Nginx反向代理
- Nginx搭建反向代理服务器过程详解
- NodeJS on Nginx: 使用nginx反向代理处理静态页面
- 最简单的nginx反向代理tomcat