Nginx常用模块介绍及配置文件说明

来源:互联网 发布:二阶张量的散度 知乎 编辑:程序博客网 时间:2024/05/21 14:50

核心功能模块

Nginx的核心功能模块负责Nginx的全局应用,主要对应主配置文件的Main区块和Event区块.

标准http功能模块

这些标准模块都不是必需的,但都是很常用的,一般默认直接安装到nginx软件中,在生产环境中,配置、调整以及优化Nginx软件,主要是通过修改这些参数来实现.

  • ngx_http_core_module 包括一些http核心参数配置
  • ngx_http_access_module 访问控制模块
  • ngx_http_gzip_module 压缩模块,优化
  • ngx_http_fastcgi_module Fast_cgi模块
  • ngx_http_proxy_module 代理模块
  • ngx_http_upsteam_module 负载均衡模块
  • ngx_http_rewrite_module Url 地址重写模块
  • ngx_http_limit_conn_module 限制用户并发连接、请求模块
  • ngx_http_limit_req_module 限制用户请求速率模块
  • ngx_http_log_module 用户访问日志模块
  • ngx_http_auth_basic_module web访问认证模块
  • ngx_http_ssl_module ssl模块,用于https连接
  • ngx_http_stub_status_module 记录Nginx基本访问状态信息等模块

nginx主配置文件

nginx.conf配置文件主要由main,events,server,http,location这五个区块组成

#Main区域worker_processess 1;error_log logs/error.log;pid logs/nginx.pid;#events区域events {worker_connections 1024;}#http区域http {include mine.types;sendfile on;default_type application/octet-stream;keepalive_timeout 65;#server 区域server {    listen 80;    server_name www.demo.com;    #location区域    location / {        root html;        index index.html index.html;       }    #location区域    locaiton = /50x.html {        root html;       }    }#server 另一个server区域 server {   listen 80;   server_name www.blog.com;   location / {      root html/blog;      index index.html;    }   location = /50x.html {       root html/blog;   }  }}
核心配置参数
#nginx.confworker_processes 1;      #worker进程的数量events {worker_connections 1024; #每个worker进程支持的最大连接数}http {includes      mime.types;    #Nginx支持的媒体类型库文件default_type  application/octet-stream;   #默认的媒体类型sendfile      on;              #开启文件高效传输模式keepalive_timeout 60;          #连接超时server {    listen 80;                 #提供服务的端口    server_name  www.demo.com; #域名    location {       root html;#站点根目录       index index.html index.htm;#默认访问的首页    }    error_page 500 502 503 504 /50x.html;#出现50x状态码时的回应    location = /50x.html { #访问50x.html页面       root html;    }}

核心框架配置

worker_processes 1;events {    worker_connections 1024;}http {    include mine.types;    server {      listen 80;      server_name www.demo.com;      location / {        root html;        index index.html index.htm;        }    }}
0 0
原创粉丝点击