nginx 2

nginx:

1. flv mp4流

2. rewrite

3. referer:链接从哪里来,,可以防止盗链;

4. worker_processes  = CPU个数(cpu密集型,计算) = cpu*1.5/2(IO密集型,读文件)

5. events->worker_connections 1024 ->单核最大连接数

6. location

 location [ = | ~ | ~* | ^~ ] {}

6.1  路径及其子路径:

location / {
    root   html;
    index  index.html index.htm;
}

 6.2 精确匹配:

location =/ {
    root   html;
    index  index.html index.htm;
}

 6.3 模式匹配/正则匹配----大小不敏感(区分):

location ~ \.php$ {
    ...;
}

 6.4 模式匹配/正则匹配--大小写不敏感(不区分)

location ~* \.(gif|jpg|jpeg) {
    ...;
}

 6.5 逐字符匹配(非正则)

location ^~ /images/ {

}

 这几种的优先级顺序:

1.  "="    精确匹配
2.  ^~    非正则匹配/逐字符匹配
3.  ~ 和 ~*  正则匹配
4.  尝试型匹配

A:  location =/ {}

B:  location / {}

C:  location /documents/ {}

D:  location ^~ /images/ {}

E:  location ~* \.(gif|jpg|jpeg) {}

例1:  / -->A

例2:  /index.htm  -->B

例3:  /documents/document.html -->C

例4:  /images/1.gif -->D

例5:  /documents/1.gif -->E

7. 限定拒绝/ 允许指定的IP访问

deny / allow

默认是allow所有访问的

拒绝/bbs 路径被 192.168.1.111访问:

location /bbs {
    root  /htdocs;
    index index.htm index.html;
    deny 192.168.1.111;
}

只允许192.168.1.112主机访问,其余全部拒绝:

location /bbs {
    root  /htdocs;
    index index.htm index.html;
    allow 192.168.1.112; 
    deny all;
}

8. autoindex 

    location 中设定: autoindex on

当访问server中所有的资源都匹配不了的时候,列出所有的资源列表。

9. stub_status -> 服务器状态信息统计; 包括处理的请求数、连接数等。

猜你喜欢

转载自niewj.iteye.com/blog/2365628