在金山逍遥网中,前端负载均衡服务器采用的是Nginx,两台Nginx服务器为一组,承担多种类型的负载均衡服务,两台负载均衡服务器均处于活动状态,各自绑定一个公网虚拟IP,作为负载均衡服务器,当其中一个发生故障时,另一台接管发生故障服务器的虚拟IP。配置nginx.conf代码如下
代码:
user www www;
work_processes 8;
error_log /data1/logs/nginx_error.log crit;
pid /usr/local/webserver/nginx/nginx.pid;
#specifies the value for maximum file descriptors that can be opened by this process worker_rlimit_nofile 51200
events
{
use epoll;
worker_connections 51200;
}
http
{
include mine.types;
default_type application/octet-strem;
#charset utf-8
server_names_hash_bucket_size 128k;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
sendfile on;
#tcp_nopush on;
keepalive_timeout 30;
tcp_nodelay on;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 128k;
gzip on;
gzip_min_length 1k;
gzip_buffers 4 16k;
gzip_http_version 1.1
gzip_comp_level 2;
gzip_types text/plain application/x-Javascript text/css application/xml;
gzip_vary on;
limit_zone anti_attack $binary_remote_addr 10m;
#允许客户端请求的最大单文件字节数
client_max_body_size 300m;
#缓冲区代理缓冲用户端的最大字节数 可以理解为现存到本地再传给用户
client_body_size 128k;
#跟后端服务器连接的超时时间_发起握手等候响应超时时间
proxy_connect_time 600;
#连接成功后_等待后端服务器响应时间_其实已经进入后端的派对等候处理
proxy_read_timeout 600;
#后端回传时间_规定时间内传完所有数据
proxy_send_timeout 600;
#代理请求缓存区,保存用户的头信息以供Nginx进行规则处理
proxy_buffer_size 16k;
proxy_buffers 4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
#缓存
proxy_temp_path /data2/proxy_temp_path;
proxy_cache_path /data2/proxy_cache_path levels=1:2 keys_zone=cache_one:200m inactive=1d max_size=5;
upstream myserver_pool{
server xx.xx.xx.1:80 weight=1 max_fails=2 fail_timeout=30s;
server xx.xx.xx.2:80 weight=1 max_fails=2 fail_timeout=30s;
server xx.xx.xx.3:80 weight=1 max_fails=2 fail_timeout=30s;
}
upstream php_server_pool{
server xx.xx.xx.4:80 weight=1 max_fails=2 fail_timeout=30s;
server xx.xx.xx.5:80 weight=1 max_fails=2 fail_timeout=30s;
server xx.xx.xx.6:80 weight=1 max_fails=2 fail_timeout=30s;
server xx.xx.xx.7:80 weight=1 max_fails=2 fail_timeout=30s;
server xx.xx.xx.8:80 weight=1 max_fails=2 fail_timeout=30s;
}
upstream bbs_server_pool{
ip=hash;
server xx.xx.xx.9:80 max_fails=2 fail_timeout=30s;
server xx.xx.xx.10:80 max_fails=2 fail_timeout=30s;
server xx.xx.xx.11:80 max_fails=2 fail_timeout=30s;
server xx.xx.xx.12:80 max_fails=2 fail_timeout=30s;
}
upstream cms_server_pool{
server xx.xx.xx.13:80 weight=1 max_fails=2 fail_timeout=30s;
server xx.xx.xx.14:80 weight=1 max_fails=2 fail_timeout=30s;
}
upstream pic_server_pool{
server xx.xx.xx.15:80 weight=1 max_fails=2 fail_timeout=30s;
server xx.xx.xx.16:80 weight=1 max_fails=2 fail_timeout=30s;
}
upstream xoyohimsg_server_pool{
server xx.xx.xx.17:3245;
server xx.xx.xx.18:3245 down;
}
#xoyo.com域名调转到
server
{
listen 80;
server_name xiyo.com;
rewrite ^/(.*) http:xoyo.com/ permanent;
acces_log /data1/logs/xoyo.com_access.log;
}
#用户中心HTTP/SSL加密浏览
server
{
listen 443;
server_name my.xoyo.com
ssl on;
ssl_cretificate my.xoyo.com.crt;
ssl_cretificate_key my.xoyo.com.key;