nginx-基础

Nginx的工作原理

Nginx作为web服务器:
Nginx是基于http协议实现的web服务器,通过epoll技术实现I/O多路复用,采用异步非阻塞实现高并发请求,异步非阻塞:1个master进程,2个work进程。

nginx是一个是高可用的http的web服务器和反向代理服务器,同时也是smtp简单邮件传输服务器

常用的配置路径

Nginx 部署-Yum,在不配置nginx的yum仓库时,默认的安装版本是1.12
版本1.12 没有默认的子配置文件
版本1.16 有默认的子配置文件

主配置文件路径是:vim /etc/nginx/nginx.conf
默认的虚拟主机配置:vim /etc/nginx/conf.d/default.conf

关于创建一个新的虚拟主机:
在这里插入图片描述

Nginx模块

状态连接模块: nginx_status

location /nginx_status {	
stub_status;   = 状态连接模块
allow all;
}

随机主页模块:random_index

location / {
     #root   /usr/share/nginx/html;
     #index  index.html index.htm;
     root /app;
     random_index on;      on=打开 off=关闭
}

替换模块:sub_filter

sub_filter nginx 'QianFeng'; = 将nginx替换为QianFeng
sub_filter_once on;
location / {
root   /usr/share/nginx/html;
index  index.html index.htm;
}

页面缓存模块: expires

    location / {
        root   /app/tianyun.me;
        index  index.html index.htm;
        expires 24h;
}

防盗链模块:valid_referers

location / {
        root   /a.com;
        index  index.html index.htm;
     
        valid_referers none blocked白名单;
        if ($invalid_referer) {
            return 403;      = 状态返回码 可以自定义
        }
}

访问限制模块:ngx_http_limit_req_module

http {
    limit_req_zone $binary_remote_addr zone=req_zone:10m rate=1r/s;     定义
	  server {
        location / {
            root /usr/share/nginx/html;
            index index.html index.htm;
            limit_req zone=req_zone;  		引用
            #limit_req zone=req_zone burst=5;
            #limit_req zone=req_zone burst=5 nodelay; 
        }
    }
}

访问控制模块:ngx_http_access_module

server {
  allow 10.18.45.65;
  allow 10.18.45.181;
  deny all;
}
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值