nginx软件功能模块说明

Nginx软件之所以强大,是因为它具有众多的功能模块,下面列出了企业常用的重要模块。

(1) Nginx核心功能模块(Core functionality)
nginx核心功能模块负责Nginx的全局应用,主要对应主配置文件的Main区块和Events区块区域,这里有很多Nginx必须的全局参数配置。有关核心功能模块的详细信息,请看官网,地址为http://nginx.org/en/docs/ngx_core_module.html。

(2)标准的http功能模块集合
这些标准的http功能模块,虽然不是nginx软件所必需的,但都是很常用的,因此绝大部分默认情况都会自动安装到 Nginx软件中(见下表),不建议擅自改动,保留软件的默认配置就好,除非你明确知道你在做什么,有什么额外影响。
在生产环境中,配置、调整及优化 Nginx软件,主要就是根据这些模块的功能修改相应的参数来实现的。通过官方地址http://nginx.org/en/docs/可以查看到上述及更多模块的详细使用帮助。

常用的Nginx http功能模块汇总

Nginx http 功能模块	               模块说明

ngx_http_core_module	           包括一些核心的http参数配置,对应nginx的配置为HTTP区块部分
ngx_http_access_module     访问控制模块,用来控制网站用户对Nginx的访问
ngx_http_gzip_module        压缩模块,对Nginx返回的数据压缩,属于性能优化模块
ngx_http_fastcgi_module      FastCGI模块,和动态应用相关的模块,例如PHP
ngx_http_proxy_module      proxy代理模块
ngx_http_upstream_module     负载均衡模块,可以实现网站的负载均衡功能及节点的健康检查
ngx_http_rewrite_module      URL地址重写模块
ngx_http_limit_conn_module   限制用户并发连接数及请求数模块
ngx_http_limit_req_module 根据定义的key限制Nginx请求过程的速率
ngx_http_log_module      访问日志模块,以指定的格式记录Nginx客户访问日志等信息
ngx_http_auth_basic_module Web认证模块,设置web用户通过账号、密码访问Nginx
ngx_http_ssl_module      ssl模块,用于加密的http连接,如htts
ngx_http_stub_status_module 记录Nginx基本访问状态信息等的模块

nginx的目录结构说明

[root@nginx ~]# tree /application/nginx/  #如果tree命令找不到需要yum install -y tree安装;
/application/nginx/
├── client_body_temp
├── conf                #这是nginx所有配置文件的目录;
│ ├── fastcgi.conf          #fastcgi相关参数的配置文件;
│ ├── fastcgi.conf.default    #fastcgi.conf的备份文件;
│ ├── fastcgi_params        #fastcgi的参数文件;
│ ├── fastcgi_params.default
│ ├── koi-utf
│ ├── koi-win
│ ├── mime.types            #mime媒体类型;
│ ├── mime.types.default
│ ├── nginx.conf          #nginx默认的主配置文件;
│ ├── nginx.conf.default
│ ├── scgi_params          #scgi相关参数文件;
│ ├── scgi_params.default
│ ├── uwsgi_params            #uwsgi相关参数文件;
│ ├── uwsgi_params.default
│ └── win-utf
├── fastcgi_temp            #fastcgi临时数据目录;  
├── html              #编译安装时nginx的默认站点目;
│ ├── 50x.html          #错误页面优雅替代显示文件,例如出现502错误时会调用此页面;
│ └── index.html          #默认的首页文件;
├── logs                #nginx默认的日志路径,报错错误日志及访问日志;
│ ├── access.log          #nginx默认的访问日志文件;
│ ├── error.log          #nginx的错误日志文件;
│ └── nginx.pid          #nginx的pid文件,nginx进程启动后,会把所有进程的ID号写入此文件;
├── proxy_temp          #临时目录;
├── sbin              #nginx的命令目录,例如nginx的启动命令nginx;
│ └── nginx          #nginx的启动命令nginx;
├── scgi_temp        #临时目录;
└── uwsgi_temp        #临时目录; 9 directories, 21 files

nginx的主配置文件 nginx.conf

nginx的主配置文件位于nginx安装目录下的conf目录中。

[root@nginx nginx]# egrep -v "#|^$" conf/nginx.conf        #去掉包含#号和空行的内容;
worker_processes 1; #worker进程的数量;
events { #事件区块开始;
worker_connections 1024; #每个worker进程支持的最大链接数;
} #事件区块结束;
http { #http区块开始;
include mime.types; #nginx支持的媒体类型文件;
default_type application/octet-stream; #默认的媒体类型;
sendfile on; #开启高效传输模式;
keepalive_timeout 65; #连接超时;
server { #第一个Server区块开始,表示一个独立的虚拟主机站点;
listen 80; #提供服务的端口默认80;
server_name localhost; #提供服务的域名主机名;
location / { #第一个location区块开始;
root html; #站点的根目录,相当于nginx的安装目录;
index index.html index.htm; #默认的首页文件,多个使用空格分开;
} #第一个location区块结束;
error_page 500 502 503 504 /50x.html; #出现对应的http状态码时,使用50x.html会回应客户;
location = /50x.html { #location区块开始,访问50x.html;
root html; #指定对应的站点目录为html;
}
}
} #http区块结束;

最新文章

  1. CSharpGL(17)重构CSharpGL
  2. C代码实现非循环单链表
  3. Leetcode: Design Snake Game
  4. js自定义事件
  5. Brief introduction to Scala and Breeze for statistical computing
  6. 黑客界大拿tombkeeper文章:怎么学好技术成为技术大拿(题目我自拟的)
  7. Oracle 自连接 / 外连接 / 子查询
  8. Word Break I II
  9. @Required 注释应用于 bean 属性的 setter 方法,它表明受影响的 bean 属性在配置时必须放在 XML 配置文件中,否则容器就会抛出一个 BeanInitializationException 异常。
  10. Python并发编程协程(Coroutine)之Gevent
  11. SPOJ VLATTICE(莫比乌斯反演)
  12. 代码文档生成工具Doxygen的使用备忘
  13. If you want an embedded database (H2, HSQL or Derby), please put it on the classpath.
  14. TF:利用TF的train.Saver载入曾经训练好的variables(W、b)以供预测新的数据—Jason niu
  15. [js]ajax-异源请求jsonp
  16. Immuable详解以及在React中的实战
  17. [cb]扩展Hierarchy 添加二级菜单
  18. 20170906xlVBA_RecursionGetFiles
  19. Android-事件分发(OnTouchEvent,OnTouch,OnClick)
  20. [BZOJ 5252][LOJ 2478][九省联考2018] 林克卡特树

热门文章

  1. C 语言实例 - 二进制与十进制相互转换
  2. "字节跳动杯"2018中国大学生程序设计竞赛-女生专场
  3. PyInstaller 库
  4. JSP && Servlet | AXIS 0配置 入门
  5. 神奇的VIM
  6. BIO,NIO,AIO总结
  7. 移动端meta的使用
  8. WGET and CURL
  9. hihocoder1860 最大异或和
  10. VC运行时库(/MD、/MT等)