#user  nobody;
worker_processes 1;##工作线程数,一般和cpu的核数相同:可通过ps -ef | nginx查看线程数 #配置错误日志位置
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; #nginx采用epoll模型
events {
#每个worker线程的连接数
#worker_processes*worker_connections为nginx支持的最大连接数,nginx官方说能支持5万连接,加入worker_processes为n。那么该值可配置5w/n
#该值还和系统能支持的最大可打开的文件数有关,可通过ulimit -a查看open files的值
#可以通过ulimit -SHn 10000 命令设置linux支持的最大打开文件数
#根据上面的两个值对该值进行合理的配置
worker_connections 1024;
} # load modules compiled as Dynamic Shared Object (DSO)
#
#dso {
# load ngx_http_fastcgi_module.so;
# load ngx_http_rewrite_module.so;
#} http {
include mime.types;
default_type application/octet-stream; #定义日志格式
#日志格式命令 日志格式名字 具体的格式内容
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"'; #使用日志格式输出一个日志(可以根据这个属性将nginx做日志采集器而不用作webserver)
#access_log logs/access.log main; #用户态设置为on表示启动高效传输文件的模式。sendfile可以让Nginx在传输文件时直接在磁盘和tcp socket之间传输数据。
#如果这个参数不开启,会先在用户空间(Nginx进程空间)申请一个buffer,用read函数把数据从磁盘读到cache,
#再从cache读取到用户空间的buffer,再用write函数把数据从用户空间的buffer写入到内核的buffer,最后到tcp socket。
#开启这个参数后可以让数据不用经过用户buffer。
sendfile on; #tcp_nopush on; #保持超时的时间
#keepalive_timeout 0;
keepalive_timeout 65; #压缩,如果打开,会把返回的内容进行压缩。会增加服务器的损耗,但是换来了带宽。如果传输的都是小文件,没有必要开
#gzip on; #定义一组服务器,配合反向代理实现负载均衡,此时keepalive_timeout应该设置为0
#upstream name {
#server ip:port
#server ip:port
#} #虚拟服务器。可以虚拟一台服务器。并允许多台虚拟服务器对应一个端口,多台虚拟server之间通过server_name区分
#nginx根据ip、port和hosts决定server
server {
listen 80; #监听的端口号
server_name localhost; #虚拟服务器的名称 #charset koi8-r; #access_log logs/host.access.log main; #对location配置不同的uri,可以分为不同的模块
#logs目录下的access.log文件中记录了请求的uri
#location的uri配置参考http://tengine.taobao.org/nginx_docs/cn/docs/http/ngx_http_core_module.html#location
location / { #访问的路径
root html; #访问的根目录,该目录是相对目录,相对于nginx的安装目录
index index.html index.htm;#首页
} #error_page 404 /404.html; # redirect server error pages to the static page /50x.html
#
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
} # proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1; ##反向代理,将请求发送给后面配置的地址。可以结合upstream做基于反向代理的负载均衡
#} # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#} # deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
} }

高可用之nginx配置文件详解的更多相关文章

  1. nginx之旅(第一篇):nginx下载安装、nginx启动与关闭、nginx配置文件详解、nginx默认网站

    一.nginx下载安装 版本nginx 1.15.5 系统环境centos7.5(本机ip192.168.199.228) 关闭selinux 和防火墙firewall 1.下载 wget http: ...

  2. 一、Nginx配置文件详解

    配置文件介绍 主要有两部分:分别是 main:主体部分 http{}:虚拟主机配置部分 配置指令主要以分号结尾:配置语法:directive value1 [value2 ....] 支持使用的变量 ...

  3. Nginx系列(10)- Nginx配置文件详解

    nginx文件结构 ... #全局块 events { #events块 ... } http #http块 { ... #http全局块 server #server块 { ... #server全 ...

  4. Nginx配置文件详解

    Nginx是一款面向性能设计的HTTP服务器,相较于Apache.lighttpd具有占有内存少,稳定性高等优势. ######Nginx配置文件nginx.conf中文详解##### #定义Ngin ...

  5. Nginx教程(五) Nginx配置文件详解

    一. Nginx配置文件nginx.conf中文详解 #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_processe ...

  6. Nginx教程(五) Nginx配置文件详解 (转)

    一. Nginx配置文件nginx.conf中文详解 #定义Nginx运行的用户和用户组 user www www; #nginx进程数,建议设置为等于CPU总核心数. worker_processe ...

  7. Nginx:Nginx配置文件详解

    Nginx是一款面向性能设计的HTTP服务器,相较于Apache.lighttpd具有占有内存少,稳定性高等优势. 如下是Nginx的配置详解: ######Nginx配置文件nginx.conf中文 ...

  8. Nginx配置文件详解与优化建议

    1.概述 今天来详解一下Nginx的配置文件,以及给出一些配置建议,希望能对大家有所帮助. 2.nginx.conf 1)配置文件位置 nginx 安装目录的 conf 文件夹下,例如:/usr/lo ...

  9. Flume NG高可用集群搭建详解

    .Flume NG简述 Flume NG是一个分布式,高可用,可靠的系统,它能将不同的海量数据收集,移动并存储到一个数据存储系统中.轻量,配置简单,适用于各种日志收集,并支持 Failover和负载均 ...

随机推荐

  1. c中函数指针和回调函数

    函数指针: 指向函数的指针.(定义的函数会分配一块内存,同变量一样存在首地址)示例如下: int Func(int x); /*声明一个函数*/ int (*p) (int x); /*定义一个函数指 ...

  2. NOIP模拟 17.8.16

    NOIP模拟17.8.16 A 债务文件名 输入文件 输出文件 时间限制 空间限制debt.pas/c/cpp debt.in debt.out 1s 128MB[题目描述]小 G 有一群好朋友,他们 ...

  3. mac上SVN的图形工具 SmartSVN注册

    mac上SVN的图形工具 SmartSVN注册 打开smartsvn,选中license注册 选中文件smartsvn.license,下一步下一步就ok了 smartsvn.license Name ...

  4. SSH免密码登录的方法

    在你的自己的机器下面使用ssh-keygen命令来实现创建公钥 将你~/.ssh目录中的id_rsa.pub这个文件拷贝到你要登录的服务器的~/.ssh目录中,然 后再运行以下命令来将公钥导入到~/. ...

  5. 【软件安装】我喜欢的notepad插件

    1.文件管理器 explorer 2.16进制查看文件工具 HEX-Editor

  6. PyChram创建虚拟环境

    目录 1. python创建虚拟环境 2. pycharm中添加python虚拟环境 1. python创建虚拟环境 首先要安装virtualenv模块.打开命令行,输入pip install vir ...

  7. LeetCode225 Implement Stack using Queues

    Implement the following operations of a stack using queues. (Easy) push(x) -- Push element x onto st ...

  8. 【JZOJ4833】【NOIP2016提高A组集训第3场10.31】Mahjong

    题目描述 解法 搜索. 代码 #include<stdio.h> #include<iostream> #include<string.h> #include< ...

  9. 在Debug模式下,如何给.lib和.dll添加一个d标记(*d.lib,*d.dll)

    选中工程->右键->属性->配置属性->常规,可以看到项目默认值的配置类型有好几种类型,选择静态库类型生成lib文件,选择动态库类型生成dll文件,选择应用程序生成exe文件, ...

  10. iOS 多个精致动画

    iOS 多个精致动画  http://www.cocoachina.com/bbs/read.php?tid=301262 iOS 零碎小知识     http://www.cocoachina.co ...