ngnix-linux

主模块{

#user  nobody;//
worker_processes  1; //几个工作进程

#worker_rlimit_core 1000KB //允许的每个程序的核心文件最大值

#worker_rlimit_nofile 102400//每个进程能够打开的最多文件描述符

#worker_cpu_affinity 001//仅用于linux下面,用来分配每个进程对应的cpu,上面一个工作进程,所以分配到一个cpu

#worker_directory path//nginx运行的绝对路径

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;

}

事件模块:events {
    worker_connections  1024;//每个工作进程的最大连接数

    //理论上的client MAC connections可以用worker_process*worker_connections来获得
}

HTTP模块:http {
    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65; //客户端与服务端的长链接时间,超过这个时间,服务端断开链接

    keepalive_requests XX//服务端保持长连接的请求数

    large_client_header_buffers 4 4k/8k,//客户端请求的头文件到缓冲区的最大值,如果URL超过这个值大小,那么返回414错误,如果头部大于这个值,那么返回400错误

    #gzip  on;

   #client_body_timeout 60//使用字段:http,server,location请求读取超时时间,指客户端与服务端建立连接,客户端在多久内后每没响应,返回一个408错误

   #client_header_buffer_size XX//使用字段,http和server,客户端请求的http头大小,一般情况下不超过1K

   #client_header_timeout   time//使用字段,http和server,使建立连接过程中,http头多长时间内没收到报错

    #client_max_body_size 8m;//使用字段,http和server,客户端请求的最大的单个文件字节数。,出现在head里面的content-length

   # log_not_found [on|off] //使用范围http,server,location当文件没找到,是不是要记录到日志里面

#open_file_cache max=N inactive=time on|off//使用范围http,server,location,max--指定缓存的最大数目,inactive缓存文件在规定时间内没被下载就移除掉

 server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

    #总之,location的作用就是把符合匹配规则网页请求跳转到规定好的,root path目录,index XX,展示的网页

        location / { //匹配规则
            root   html;// root path,如果有符合规则的网页,就跳转到html目录下面
            index  index.html index.htm;//哪些文件用于主页

            limit_except GET{//limit_except用在location里面,用来拒绝来自某些方面的请求

    allow 127.0.0.1;

   deny all;

}
        }

        #error_page  404              /404.html; //错误返回码可以自己定义.如error_page 404=200 /200.php

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;

        location /404.html {

internal;//作用是用来防止某个网页被用户访问到,这里指以404.html结尾的页面不被用户访问到

}
        location = /50x.html {
            root   html;
        }

        # proxy the PHP scripts to Apache listening on 127.0.0.1:80
        #
        #location ~ \.php$ {
        #    proxy_pass   http://127.0.0.1;
        #}

        # pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
        #
        #location ~ \.php$ {
        #    root           html;
        #    fastcgi_pass   127.0.0.1:9000;
        #    fastcgi_index  index.php;
        #    fastcgi_param  SCRIPT_FILENAME  /scripts$fastcgi_script_name;
        #    include        fastcgi_params;
        #}

        # deny access to .htaccess files, if Apache's document root
        # concurs with nginx's one
        #
        #location ~ /\.ht {
        #    deny  all;
        #}
    }

    # another virtual host using mix of IP-, name-, and port-based configuration
    #
    #server {
    #    listen       8000;
    #    listen       somename:8080;
    #    server_name  somename  alias  another.alias;

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

    # HTTPS server
    #
    #server {
    #    listen       443;
    #    server_name  localhost;

    #    ssl                  on;
    #    ssl_certificate      cert.pem;
    #    ssl_certificate_key  cert.key;

    #    ssl_session_timeout  5m;

    #    ssl_protocols  SSLv2 SSLv3 TLSv1;
    #    ssl_ciphers  HIGH:!aNULL:!MD5;
    #    ssl_prefer_server_ciphers   on;

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

}

posted @ 2012-03-29 15:04  RINA  阅读(358)  评论(0编辑  收藏  举报