nginx配置文件祥解

nginx配置说明----------------------------

创新互联公司坚持“要么做到,要么别承诺”的工作理念,服务领域包括:成都网站建设、成都网站设计、企业官网、英文网站、手机端网站、网站推广等服务,满足客户于互联网时代的安康网站设计、移动媒体设计的需求,帮助企业找到有效的互联网解决方案。努力成为您成熟可靠的网络建设合作伙伴!

#运行用户
usernobody nobody;
#启动进程
worker_processes2;
#全局错误日志及PID文件
error_loglogs/error.log notice;
pidlogs/nginx.pid;
#工作模式及连接数上限
events {
use epoll;
worker_connections1024;
}
#设定http服务器,利用它的反向代理功能提供负载均衡支持
http {
#设定mime类型
includeconf/mime.types;
default_typeapplication/octet-stream;
#设定日志格式
log_format main\'$remote_addr - $remote_user [$time_local] \'
\'"$request" $status $bytes_sent \'
\'"$http_referer" "$http_user_agent" \'
\'"$gzip_ratio"\';
log_format download \'$remote_addr - $remote_user [$time_local] \'
\'"$request" $status $bytes_sent \'
\'"$http_referer" "$http_user_agent" \'
\'"$http_range" "$sent_http_content_range"\';
#设定请求缓冲
client_header_buffer_size1k;
large_client_header_buffers4 4k;
#开启gzip模块
gzip on;
gzip_min_length1100;
gzip_buffers4 8k;
gzip_typestext/plain;
output_buffers1 32k;
postpone_output1460;
#设定access log
access_loglogs/access.logmain;
client_header_timeout3m;
client_body_timeout3m;
send_timeout3m;
sendfileon;
tcp_nopushon;
tcp_nodelayon;
keepalive_timeout65;
#设定负载均衡的服务器列表
upstream mysvr {
#weigth参数表示权值,权值越高被分配到的几率越大
#本机上的Squid开启3128端口
server 192.168.8.1:3128 weight=5;
server 192.168.8.2:80weight=1;
server 192.168.8.3:80weight=6;
}
#设定虚拟主机
server {
listen80;
server_name192.168.8.1 www.yejr.com;
charset gb2312;
#设定本虚拟主机的访问日志
access_loglogs/www.yejr.com.access.logmain;
#如果访问 /img/*, /js/*, /css/* 资源,则直接取本地文件,不通过squid
#如果这些文件较多,不推荐这种方式,因为通过squid的缓存效果更好
location ~ ^/(img|js|css)/{
root/data3/Html;
expires 24h;
}
#对 "/" 启用负载均衡
location / {
proxy_passhttp://mysvr;
proxy_redirectoff;
proxy_set_headerHost $host;
proxy_set_headerX-Real-IP $remote_addr;
proxy_set_headerX-Forwarded-For $proxy_add_x_forwarded_for;
client_max_body_size10m;
client_body_buffer_size 128k;
proxy_connect_timeout90;
proxy_send_timeout90;
proxy_read_timeout90;
proxy_buffer_size4k;
proxy_buffers4 32k;
proxy_busy_buffers_size 64k;
proxy_temp_file_write_size 64k;
}
#设定查看Nginx状态的地址
location /NginxStatus {
stub_statuson;
access_logon;
auth_basic"NginxStatus";
auth_basic_user_fileconf/htpasswd;
}
}
}
备注:conf/htpasswd 文件的内容用 apache 提供的 htpasswd 工具来产生即可,内容大致如下:
3.) 查看 Nginx 运行状态
输入地址 http://192.168.8.1/NginxStatus/,输入验证帐号密码,即可看到类似如下内容:
Active connections: 328
server accepts handled requests
9309898228890
Reading: 1 Writing: 3 Waiting: 324

第一行表示目前活跃的连接数
第三行的第三个数字表示Nginx运行到当前时间接受到的总请求数,如果快达到了上限,就需要加大上限值了。
第四行是Nginx的队列状态

当前标题:nginx配置文件祥解
网站路径:https://www.cdcxhl.com/article18/cgpodp.html

成都网站建设公司_创新互联,为您提供网站排名手机网站建设响应式网站云服务器关键词优化虚拟主机

广告

声明:本网站发布的内容(图片、视频和文字)以用户投稿、用户转载内容为主,如果涉及侵权请尽快告知,我们将会在第一时间删除。文章观点不代表本网站立场,如需处理请联系客服。电话:028-86922220;邮箱:631063699@qq.com。内容未经允许不得转载,或转载时需注明来源: 创新互联

成都做网站