nginx的各个模块说明

1.nginx.conf文件说明:
server {
    listen       80;
    server_name  www.oldzb.com;
        location / {
        root /usr/share/nginx/html;
        autoindex on;                            --- 开启nginx站点目录索引功能,搭建文件共享服务器
        charset utf-8;                            --- 修改目录结构中出现的中文乱码问题
        }

        location /zb {
        root   /usr/share/nginx/html;
        index  oldboy.html;
        deny 192.168.223.0/24;                    --- 拒绝这个网段访问
        allow 172.16.1.132;                        --- 允许这个IP访问    
        stub_status;                            --- 对网站进行监控
        auth_basic           "zhoubo";            --- 开启用户访问认证
        auth_basic_user_file passwd/htpasswd;    --- 用户认证密码,可以用htpasswd命令生成(htpasswd -bc htpasswd zhoubo 123456)
        if ($host ~* "^oldzb.com$") {
            rewrite ^/(.*) http://www.oldzb.com/$1 permanent;
            }   
                                 --- 输入oldzb.com会直接跳转到www.oldzb.com

         return 404;---- 直接返回404页面
        }
    error_page   500 502 503 504  /50x.html;
    location = /50x.html {
        root   /usr/share/nginx/html;
    }

}

2.nginx日志说明:
    $remote_addr               显示用户访问源IP地址信息
    $remote_user            显示认证的用户名信息
    [$time_local]           显示访问网站时间
    "$request"              请求报文的请求行信息
    $status                 用户访问网站状态码信息
    $body_bytes_sent        显示响应的数据尺寸信息
    $http_referer           记录调用网站资源的连接地址信息(防止用户盗链)                    
    $http_user_agent        记录用户使用什么客户端软件进行访问页面的  (谷歌 火狐 IE 安卓 iphone)

3.location详细配置:
    Syntax:    location [ = | ~ | ~* | ^~ ] uri { ... }
            location @name { ... }
    Default:    —
    Context:    server, location
    location = / {              --- 精确匹配    优先级01 最高
    [ configuration A ]
    }
    
    location / {                --- 默认匹配    优先级04 最低
        [ configuration B ]
    }
    
    location /documents/ {      --- 按照目录进行匹配    优先级03
        [ configuration C ]
    }
    
    location ^~ /images/ {      --- 优先匹配/不识别uri信息中符号信息       优先级02
        [ configuration D ]
    }
     
    location ~* \.(gif|jpg|jpeg)$ {  --- 不区分大小写进行匹配  优先级03
        [ configuration E ]
    }

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值