创建目录索引

    cd /etc/nginx/conf.d

    vim mulusouyin.conf

    server {

    listen 80;

    charset utf-8,gbk;

            location / {

            root /module;

            autoindex on;

            autoindex_exact_size off;    【显示确切的大小】

            autoindex_locatime on;    【显示本地时间】

        }

    }

实现界面效果

    

 

nginx状态模块【--with-http_stub_status_module】

配置文件中添加location

    location /nginx_status {

    stub_status;

    }

效果如下:

Active connections # 当前活动客户端连接数,包括Waiting等待连接数。

accepts # 已接受总的TCP连接数。

handled # 已处理总的TCP连接数。

requests # 客户端总的http请求数。

Reading # 当前nginx读取请求头的连接数。

Writing # 当前nginx将响应写回客户端的连接数。

Waiting # 当前等待请求的空闲客户端连接数。

# 注意, 一次TCP的连接,可以发起多次http的请求, 如下参数可配置进行验证

keepalive_timeout 0; # 类似于关闭长连接

keepalive_timeout 65; # 65s没有活动则断开连接

 

访问控制模块【ngx_http_access_module】

配置文件中直接添加

    location /nginx_status {

    stub_status;

    deny 10.0.0.1/32;    【拒绝10.0.0.1访问】

    allow 10.0.0.1/32;    【允许10.0.0.1访问】

    allow all;        【允许所有人】

    deny all;        【拒绝所有人】

    }

 

身份验证模块【ngx_http_auth_basic_module】

生成一个密码文件:

yum install httpd-tools -y

htpasswd -c -b /etc/nginx/auth_conf oldboy oldboy

配置nginx,限制对应的资源

配置文件中添加location

    location /download {

    root /module;

    auth_basic "Please Password!!!";

    auth_basic_user_file /etc/nginx/auth_conf;

    }

效果如下:

 

 

 

 

 

 

 

posted on 2019-05-03 12:08  叶秀儿  阅读(111)  评论(0编辑  收藏  举报