标签:shell
修改nginx配置文件:
user www www;
worker_processes 1;
error_log /usr/local/nginx/logs/nginx_error.log crit;
pid /usr/local/nginx/logs/nginx.pid; //nginx进程id
worker_rlimit_nofile 51200;//文件最大连接数,系统限定文件ulimit对服务也会有影响,使用ulimit -n可以查看,修改/etc/security/limits.conf
events
{
use epoll;//高效模式
worker_connections 51200;
}
http
{
include mime.types; //配置文件模块
default_type application/octet-stream; //核心配置文件模块
source_charset GB2312; //字符集 GB2312
server_names_hash_bucket_size 256; //
client_header_buffer_size 256k;
large_client_header_buffers 4 256k;
#size limits
client_max_body_size 50m;
client_body_buffer_size 256k;
client_header_timeout 3m;
client_body_timeout 3m;
send_timeout 3m;
sendfile on;
tcp_nopush on;
keepalive_timeout 120;
tcp_nodelay on;
upstream www.dragon.com {
server 192.168.1.116:80 weight=8 max_fails=2 fail_timeout=30s;
server 192.168.1.115:80 weight=8 max_fails=2 fail_timeout=30s;
}
//根据weight权重指定分配轮询,达到负载均衡。
server
{
listen 80;
server_name bbs.linuxtone.conf;
charset GB2312;
index index.html index.htm;
root /date/wwwroot/linuxtone/;
location ~ ^/NginxStatus/ {
stub_status on;
access_log off;
}
location / {
proxy_redirect off ; // 如果需要从后端打开location 和Refresh 字段,可以开启。
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header REMOTE-HOST $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size 50m;
client_body_buffer_size 256k;
proxy_connect_timeout 30; //连接超时时间30s
proxy_send_timeout 30;
proxy_read_timeout 60; // 连接成功等待后端相应的时间,默认是60S
proxy_buffer_size 256k; // 代理服务器的缓存文件头部文件大小,默认是4K
proxy_buffers 4 256k; // 后端真是服务器的数量和大小
proxy_busy_buffers_size 256k; // 当系统忙事,申请更大proxy_buffer
proxy_temp_file_write_size 256k; // 写入临时目录的文件大小
proxy_next_upstream error timeout invalid_header http_500 http_503 http_404;
proxy_max_temp_file_size 128m;
proxy_pass http://www.dragon.com;//指定代理域名
}
}
}
域名被分配到不同ip的服务器上解析。
本文转自:维斯亚综合论坛:http://www.w4ya.com/forum.php?mod=post&action=edit&fid=53&tid=104&pid=104&page=1
本文出自 “龙爱雪琪” 博客,谢绝转载!
标签:shell
原文地址:http://dragon123.blog.51cto.com/9152073/1585219