1. 设定网站的根目录:

    1. alias /dir
    2. root /dir
  2. gzip压缩

    1
    2
    3
    4
    5
    
    gzip on
    gzip_min_length 1;#最小压缩字节
    gzip_comp_level 2;#压缩级别
    gzip_types image/png text/plain
       
    
  3. 列出文件

    1
    2
    3
    
    location / {
      autoindex on;
    }
    
  4. 限制传输速度

    1
    2
    3
    4
    5
    6
    7
    
    server {
    
    if ($slow) {
        set $limit_rate 4k;
    }
       
    }
    
  5. Nginx日志格式:

    1
    2
    3
    
    log_format  need  '$http_x_forwarded_for - $remote_user  [$time_local]  '
                         ' "$request"  $status $body_bytes_sent '
                         ' "$http_referer"  "$http_user_agent" $request_time ';