ngin 模块及模板
发布日期:2021-05-09 07:04:52 浏览次数:18 分类:博客文章

本文共 13752 字,大约阅读时间需要 45 分钟。

nginx���������

server {        listen 80;        server_name www.abc.com;        access_log /var/log/nginx/www.abc.com.log;        location / {        root    /dir;        index /a.txt;        access_log /var/log/nginx/www.abc.com.dir.log;        }}nginx������������������������������������������������������github������������������nginx������������wget,yum,windows������������������������������������������������������������������������������������������������������������������������nginx������������������������������������	������������������������http���	http������������server������location���yum���������������nginx������include������������nginx���������includelocation / ������������������������root���index������������������������������������������root���alias������������������������������������������������403������index���autoindex���������������������������������������������403���root������������alias���������������alias���������������������index������������autoindex������������������������������������������������������������������������������������������root��������� / ������������������������������������������index������������������������������������,html������������������������������������������������������������nginx���������������������������������������access.log	������������������nginx������������������������������������error.log	���������������������nginx������������/etc/nginx/conf.d/default.conf	������������������nginx���������������������������������������������������������������HTML���������error_page,location)/usr/share/nginx/html	���������������������nginx������������������������������������������root���������������/50.html,html/50html���������/usr/share/nginx/html/50x.html 	nginx���������50x ���������������	/usr/share/nginx/html/index.html	������������nginx���������html������������IP���������������localhost���������������/etc/logrotate.d/	centos7���������������������������������������������������nginx���mysql���yum���������������������������������	������server���������������������������location���������������������������������nginx���������������������������������������������������������html������������nginx������������������������nginx���������������������������������������������������������������������������������������������������������������������������������������������������������401	���������������

nginx������

index������

������������html���������������html������������������html������

1.������server������vim /etc/nginx/conf.d/syy1.conf server {        listen 80;        server_name www.abc.com;        location / {        root    /dir;        index index.html;        }}2.������������������������nginx -tnginx -s reload3.������������������mkdir /dir4.������html������������������������5.windows���������������6.���������������F5	alt+F5	F12+network+cache	������������������

autoindex������

1.������server������vim /etc/nginx/conf.d/syy1.conf server {        listen 80;        server_name www.abc.com;        location / {        root    /dir;           autoindex on;        }}2.���������������nginx -tnginx -s reload3.������������������mkdir /dir4.������������������������html,htm������5.windows���������������6.���������������F5	alt+F5	F12+network+cache	������������������

���������������

charset utf-8,gbk;

autoindex_exact_size������

on ������������������������

off ������������������������������

������������������������������������������������������������������������������������������������

1.������server������vim /etc/nginx/conf.d/syy1.conf server {        listen 80;        server_name www.abc.com;        charset utf-8,gbk;        autoindex_exact_size off;                location / {        root    /dir;           autoindex on;        }}2.���������������nginx -tnginx -s reload3.������������������mkdir /dir4.������������������������html������5.windows���������������6.���������������F5	alt+F5	F12+network+cache	������������������

autoindex_localtime on

on ���������������������

off ���������������������������

���������������������������������������������

1.������server������vim /etc/nginx/conf.d/syy1.conf server {        listen 80;        server_name www.abc.com;        charset utf-8,gbk;        autoindex_exact_size off;        autoindex_localtime off;                location / {        root    /dir;           autoindex on;        }}2.���������������nginx -tnginx -s reload3.������������������mkdir /dir4.������������������������html������5.windows���������������6.���������������F5	alt+F5	F12+network+cache	������������������

ngx_http_stub_status_module������

���������������������������������������������...

������������������������allow���deny

1.������server������vim /etc/nginx/conf.d/syy1.conf server {        listen 80;        server_name www.abc.com;        location = /basic_status {        stub_status;        }}2.���������������nginx -tnginx -s reload3.���������������http://www.abc.com/basic_statusF5	alt+F5	F12+network+cache	������������������#������������location        location = /zt {        stub_status;        }#������������allow���deny���������allow������deny���        location = /zt {        stub_status;        allow 10.0.0.0/24;        deny all;        }

ngx_http_auth_basic_module������

���������������server���������location������������������������������������������location������

���������������������������������������������������������location������������

���������������������������������������������������������������������������������

������������������������������������

1.������server������vim /etc/nginx/conf.d/syy1.conf server {        listen 80;        server_name www.abc.com;	   location / {        root    /dir;           autoindex on;                auth_basic           "closed site";        auth_basic_user_file /dir/htpasswd;        }        location = /zt {        stub_status;        }}2.������������������#������������server���������������������������������������������������������������������������nginx -tnginx -s reload3.������������������mkdir /dir������������������������������������������������������location������������html������������htpasswd -b -c /dir/htpasswd syy 1234.������������������������html������5.windows���������������6.���������������F5	alt+F5	F12+network+cache	������������������

ngx_http_access_module

���������������server���������location������������������������������������������location������

������������������������IP���������������������������������������������

basic���access ������������������������������

������allow���deny���������

vim /etc/nginx/conf.d/syy1.conf +13server {        listen 80;        server_name www.abc.com;        location / {        root    /dir;        autoindex on;        #auth_basic           "closed site";        #auth_basic_user_file /dir/htpasswd;        allow 10.0.0.0/24;        deny  all;}        location = /zt {        stub_status;        }}
vim /etc/nginx/conf.d/syy1.conf +13server {        listen 80;        server_name www.abc.com;        location / {        root    /dir;        autoindex on;        #auth_basic           "closed site";        #auth_basic_user_file /dir/htpasswd;}        location = /zt {        stub_status;        allow 10.0.0.0/24;        deny all;        }}#������curl������������������������curl http://syy:123@www.syy1.com/zt

���������������������

ngx_http_limit_conn_module������

���������������������������������500������������������������IP���������

������500���������������������������������403

1.���������������vim /etc/nginx/nginx.conf  limit_conn_zone $binary_remote_addr zone=perip���10m; limit_conn_zone $server_name zone=perserver���10m;2.���������������vim /etc/nginx/conf.d/syy1.conf server {        listen 80;        server_name www.syy1.com;        limit_conn perip 3;        limit_conn perserver 3;        location / {                root /code/syy1;                #index index.html;                autoindex on;                }        }3.nginx -s reload4.��������� ���������server������������������location

������ab��������������������������� / ������������������������������������

-c	:���������������-n	:���������������������������#���������������/ab -c100 -n 1000 http://www.syy1.com/

ngx_http_limit_req_module ������

���������������������������������

���������������������������503

1.���������������������������vim /etc/nginx/nginx.conf limit_req_zone $binary_remote_addr zone=perip:10m rate=1r/s;limit_req_zone $server_name zone=perserver:10m rate=10r/s;2.���������������������vim /etc/nginx/conf.d/syy1.conf +5server {        listen 80;        server_name www.syy1.com;    limit_req zone=perip burst=1 nodelay;    limit_req zone=perserver burst=1;            location / {                root /code/syy1;                #index index.html;                autoindex on;        }}3.���������������������503 Service Temporarily Unavailable ���503���������������������������������������������

������������������������

���������������������������400-599���,������������������������������������������

1.��������������� ������IP'������'������������������������������ ���������'���������'vim /etc/nginx/conf.d/syy1.conf +5server {        listen 80;        server_name www.syy1.com;    limit_req zone=perip burst=1 nodelay;    limit_req zone=perserver burst=1;    limit_req_status 412;        location / {                root /code/syy1;                #index index.html;                autoindex on;        }}2.���������������������412 Precondition Failed3.������������������������������[root@web01 ~]# tailf /var/log/nginx/access.log10.0.0.1 - syy [19/May/2020:01:02:32 +0800] "GET / HTTP/1.1" 412 575 "-" "Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36" "-"

��������������������� HTML������

1.��������������� ������IP'������'������������������������������ ���������'���������'vim /etc/nginx/conf.d/syy1.conf +5server {        listen 80;        server_name www.syy1.com;    limit_req zone=perip burst=1 nodelay;    limit_req zone=perserver burst=1;    limit_req_status 412;    error_page 412 /syy1.html;        location / {                root /code/syy1;                #index index.html;                autoindex on;                auth_basic           "aaa";                auth_basic_user_file /code/htpasswd;        }}2.������412 HTML������vim /code/syy1/syy1.html             
������

412 Precondition Failed

������������ 3.������nginx4.���������������������

nginx������������

0.0>������������yum������������������nginx0.1> ������������������������������1.���������������vim /etc/nginx/nginx.conf  limit_conn_zone $binary_remote_addr zone=perip:10m; limit_conn_zone $server_name zone=perserver:10m;limit_req_zone $binary_remote_addr zone=perip2:10m rate=1r/s;limit_req_zone $server_name zone=perserver2:10m rate=10r/s;2.������server������vim /etc/nginx/conf.d/syy1.conf server {        listen 80;        server_name www.abc.com;                access_log /var/log/nginx/www.abc.com.access.log main;    	error_log /var/log/nginx/www.abc.com.error.log;                #���������        charset utf-8,gbk;        #������������������        autoindex_exact_size off;        #������������������������        autoindex_localtime off;        #������������������������        auth_basic           "closed site";        auth_basic_user_file /dir/htpasswd;        #������������        deny 10.0.0.1;        allow 10.0.0.0/24;        deny  all;                #���������������zt���location���������������������        location = /zt {        stub_status;        allow 10.0.0.0/24;        deny all;        }                  #������������IP���������        limit_conn perip 3;        limit_conn perserver 3;        #������������������        limit_req zone=perip2 burst=1 nodelay;        limit_req zone=perserver2 burst=1;                #���������������������������html������        location / {        root	/dir;        index index.html;                #������������������������������������������        limit_req_status 412;        error_page 412 /412.html;                     }        #���������������������        location /abc {        root    /dir;           autoindex on;        }                #���������������  .*\.(svn|git|cvs)  ������������  ������ tt.svn  .git .cvs		location ~ .*\.(svn|git|cvs) {		deny all;        }		# ���������������������   .*\.htm|html|xml|shtml   ->������ expires		location ~* \.(htm|html|xml|shtml)$ {		expires 600;    #���         }		location  ~* \.(js|css)$ {	    expires 30d;      #���        }		location ~* \.(mp3|htc|gif|ico|png|swf|jpg|jpeg|bmp)$ {         etag off;         #������������        }                #������������������������������������������������/dir/*.html ���������������		error_page  400 = /dir/400.html;		error_page  404 = /dir/404.html;		error_page  500 = /dir/500.html;		error_page  502 = /dir/502.html;}3.������nginx -tnginx -s reload4.������������������mkdir /dir/abc -p5.������html���������������HTML������vim /dir/abc/index.html6.������412 HTML������,400,404,500,502(#������������html���������������������������)vim /dir/412.html 7.basic������������������������������������������������������������location������������html������������htpasswd -b -c /dir/htpasswd syy 1238.������ ���������������������������location������ ������������������html������rm -rf /dir/abc/*.htm*9.windows���������������10.0.0.7 www.abc.com10.���������������,#���������������������������������������������������������������������������������������������������������������html������������������������index.html������������������html������������������������������������location������������������F5	alt+F5	F12+network+cache	������������������11.������������������������������[root@web01 ~]# tailf /var/log/nginx/www.abc.com.access.log
上一篇:scgi_params
下一篇:nginx常用模块

发表评论

最新留言

很好
[***.229.124.182]2025年04月05日 11时06分00秒