text: #Nginx所用用户和组，window下不指定  
  #user  nobody;  
    
  #工作的子进程数量（通常等于CPU数量或者2倍于CPU）  
  worker_processes  2;  
    
  #错误日志存放路径  
  #error_log  logs/error.log;  
  #error_log  logs/error.log  notice;  
  error_log  logs/error.log  info;  
    
  #指定pid存放文件  
  pid        logs/nginx.pid; 
  
  #master_process  off; # 简化调试 此指令不得用于生产环境 
  #daemon          off; # 简化调试 此指令可以用到生产环境
    
  #最大文件描述符
  worker_rlimit_nofile 51200;
  
  events {  
      #使用网络IO模型linux建议epoll，FreeBSD建议采用kqueue，window下不指定。  
      #use epoll;  
        
      #允许最大连接数  
      worker_connections  2048;  
  } 
  
  # load modules compiled as Dynamic Shared Object (DSO)
  #
  #dso {
  #    load ngx_http_fastcgi_module.so;
  #    load ngx_http_rewrite_module.so;
  #}
    
  http {  
      include       mime.types;
      
      #反向代理配置
      include    proxy.conf;
      include    gzip.conf;
      
      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  off;  
      access_log  logs/access.log main;  
    
      client_header_timeout  3m;  
      client_body_timeout    3m;  
      send_timeout           3m;  
     
      client_header_buffer_size    1k;  
      large_client_header_buffers  4 4k; 
      
      #允许客户端请求的最大单文件字节数
      client_max_body_size 10m; 
  
      #缓冲区代理缓冲用户端请求的最大字节数，
      client_body_buffer_size 128k;
      
      client_body_in_single_buffer on;
    
      sendfile        on;  
      #tcp_nopush      on;  
      #tcp_nodelay     on;  
    
      keepalive_timeout  65; 
      
      ##for genarate uuid
      #lua_package_path 'uuid4.lua';
      #init_by_lua '
      #  uuid4 = require "uuid4"
      #';
      
      upstream upstream_test{  
          server 127.0.0.1:8080;
  
          #ip_hash;
          keepalive 30;
        
          ## tengine config
          #check interval=300 rise=10 fall=10 timeout=100 type=http port=80;
          #check_http_send "GET / HTTP/1.0\r\n\r\n";
          #check_http_expect_alive http_2xx http_3xx;
  
          ## tengine config
          #session_sticky cookie=cookieTest mode=insert;
      }  
    
      server {  
          listen       80;  
          server_name  domain.com somename  alias  another.alias;  
      
          if ($host !~* www.domain.com) { #如果访问时没有加www，则跳转至www.domain.com
              rewrite ^(.*)$ http://www.domain.com/$1 permanent;
          }
    
          location / {
              autoindex  on; #允许目录浏览
              autoindex_exact_size  off; #显示文件大概大小
              autoindex_localtime on; #显示的文件时间为文件的服务器时间，off则为GMT时间
              limit_rate_after 10m; #10m之后下载速度为10k
              limit_rate 10k;
          
              root html;
              index  index.html index.htm;  
          } 
           
          location /proxy {
              proxy_pass http://upstream_test;  
              #配置跨域访问
              add_header 'Access-Control-Allow-Headers' 'Content-Type';  
              add_header 'Access-Control-Allow-Origin' '*';  
              add_header 'Access-Control-Allow-Methods' 'GET';
              add_header 'Access-Control-Expose-Headers' 'Access-Control-Allow-Origin,Access-Control-Allow-Credentials';
          } 
        
          location ^~ /resources/ {
              alias /data/resources/;
              access_log  off;
              expires  30d;
          }
        
          ## for images、html static files
          location ~* ^/static/.*\.(jpg|jpeg|gif|png|html|htm|swf)$ {
              root /data/static/;
              access_log  off;
              expires  30d;
          }
        
          ## for js、css static files
          location ~* \.(js|css)$ {
              root /data/static/;
              access_log  off;
              expires  1d;
          }
      
          ## nginx lua example
      
          #location /test-uuid{
          #    set_by_lua $uuid 'return uuid4.getUUID() ';
  
          #    echo $uuid;
          #}
          
          #location /test-io{
          #    set_by_lua $uuid '
          #       local t = io.popen("cat /data/test")
          #       return t:read("*all")
          #    ';
  
          #    echo $uuid;
          #}
        
          #location /inline_concat {
              # MIME type determined by default_type:
          #    default_type 'text/plain';
   
          #    set $a "hello";
          #    set $b "world";
              # inline Lua script
          #    set_by_lua $res "return ngx.arg[1]..ngx.arg[2]" $a $b;
          #    echo $res;
          #}
          
          #location /lua_test{
          #    default_type 'text/plain';
          #    content_by_lua ' 
          #    if jit then 
          #        ngx.say(jit.version) 
          #    else 
          #        ngx.say(_VERSION) 
          #    end 
          #    '; 
          #}
  
          location /nginx_status {
              stub_status on;
              access_log off;
              allow 127.0.0.1;#设置为可访问该状态信息的ip
              deny all;
          }
    
          ## tengine upstream status    
          #location /upstream_status {
          #    check_status;
  
          #    access_log off;
          #    allow 127.0.0.1;
          #    deny all;
          #}
  
          error_page   500 502 503 504  /50x.html;
          location = /50x.html {
              root   html;
          }
      }
     
      ## rewrite example
      #server {  
      #    listen       8090;  
      #    server_name  127.0.0.1;     
    
      #    location / {
      #        rewrite ^(.*) http://125.76.215.230/test/ last;
      #    } 
      #}
    
      # HTTPS server
      #
      #server {
      #    listen       443 ssl;
      #    server_name  localhost;
  
      #    ssl_certificate      cert.pem;
      #    ssl_certificate_key  cert.key;
  
      #    ssl_session_cache    shared:SSL:1m;
      #    ssl_session_timeout  5m;
  
      #    ssl_ciphers  HIGH:!aNULL:!MD5;
      #    ssl_prefer_server_ciphers  on;
  
      #    location / {
      #        root   html;
      #        index  index.html index.htm;
      #    }
      #}
  }
  