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

核心功能模块

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.conf
worker_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;
        }
    }
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值