dog1888 发表于 2018-11-14 12:31:04

nginx 多盘做缓存

worker_processes8;  

  
#error_loglogs/error.log;
  
#error_loglogs/error.lognotice;
  
#error_loglogs/error.loginfo;
  

  
#pid      logs/nginx.pid;
  

  

  
events {
  
    worker_connections65535;
  
}
  

  

  
http {
  
    include       mime.types;
  
    default_typeapplication/octet-stream;
  

  
    log_formatmain'$remote_addr - $remote_user [$time_local] "$request" '
  
                      '$status $body_bytes_sent "$http_referer" '
  
                      '"$http_user_agent" "$http_x_forwarded_for" "$upstream_cache_status" "$host" "$request_time"';
  

  
    access_loglogs/access.logmain;
  

  
    sendfile      on;
  
    #tcp_nopush   on;
  

  
    #keepalive_timeout0;
  
    keepalive_timeout65;
  
    resolver8.8.8.8;
  

  
    #gzipon;
  
client_body_buffer_size512k;
  
proxy_connect_timeout    5;
  
proxy_read_timeout       60;
  
proxy_send_timeout       5;
  
proxy_buffer_size      16k;
  
proxy_buffers            4 64k;
  
proxy_busy_buffers_size 128k;
  
proxy_temp_file_write_size 128k;
  
proxy_temp_path   /data/tmp;
  

  
proxy_cache_path/data/cache1levels=1:2   keys_zone=cache_1:200m inactive=365d max_size=112g use_temp_path=off;
  
proxy_cache_path/data/cache2levels=1:2   keys_zone=cache_2:200m inactive=365d max_size=120g use_temp_path=off;
  
proxy_cache_path/data/cache3levels=1:2   keys_zone=cache_3:200m inactive=365d max_size=120g use_temp_path=off;
  
proxy_cache_path/data/cache4levels=1:2   keys_zone=cache_4:200m inactive=365d max_size=120g use_temp_path=off;
  
proxy_cache_path/data/cache5levels=1:2   keys_zone=cache_5:200m inactive=365d max_size=120g use_temp_path=off;
  

  
split_clients $request_uri $disk {
  
      20% 1;
  
      20% 2;
  
      20% 3;
  
      20% 4;
  
      20% 5;
  
}
  

  
#server {
  
#      listen   80 default_server;
  
#      server_name _;
  

  
#       location / {
  
#               return 403;
  
#       }
  
#}
  

  
server {
  
      listen       80;
  
       # server_namehpcc-page.cnc.ccgslb.com.cn img3.2345.com;
  
      location / {
  
      proxy_set_header Accept-Encoding "";
  
      proxy_pass http://$host;
  
      proxy_cache_key $request_uri;
  
      proxy_cache cache_$disk;
  
      proxy_cache_valid 200 302 1d;
  
      proxy_cache_valid 404      1d;
  
      #aio threads=pool_$disk;
  
      add_headerNginx-Cache "$upstream_cache_status";
  
                        sendfile on;
  
      }
  

  
      location /nginx_status {
  
          stub_status on;
  
          access_log   off;
  
          allow 127.0.0.1;
  
          deny all;
  
      }
  

  
}
  

  
}


页: [1]
查看完整版本: nginx 多盘做缓存