Chinaunix首页 | 论坛 | 博客
  • 博客访问: 4176129
  • 博文数量: 601
  • 博客积分: 15410
  • 博客等级: 上将
  • 技术积分: 6884
  • 用 户 组: 普通用户
  • 注册时间: 2007-05-16 08:11
个人简介

独学而无友,则孤陋而寡闻!

文章分类

全部博文(601)

文章存档

2020年(1)

2018年(4)

2017年(7)

2016年(42)

2015年(25)

2014年(15)

2013年(36)

2012年(46)

2011年(117)

2010年(148)

2009年(82)

2008年(37)

2007年(41)

分类: 系统运维

2013-01-03 20:26:41

  1. #需要建立www用户和www用户组  
  2. user  www www;  
  3. worker_processes  8;  
  4.   
  5. error_log  /usr/local/nginx-0.8.32/logs/error.log crit;  
  6.   
  7. pid  /usr/local/nginx-0.8.32/nginx.pid;  
  8.   
  9. events {  
  10.     use epoll;  
  11.     worker_connections  65535;  
  12. }  
  13.   
  14. http {  
  15.     include       mime.types;  
  16.     default_type  application/octet-stream;  
  17.   
  18.     charset  utf-8;            
  19.     server_names_hash_bucket_size 128;     
  20.     client_header_buffer_size 32k;     
  21.     large_client_header_buffers 4 32k;     
  22.     client_max_body_size 300m;            
  23.     sendfile on;     
  24.     tcp_nopush     on;  
  25.   
  26.     keepalive_timeout 60;  
  27.     tcp_nodelay on;      
  28.     client_body_buffer_size  512k;     
  29.     proxy_connect_timeout    5;     
  30.     proxy_read_timeout       60;     
  31.     proxy_send_timeout       5;     
  32.     proxy_buffer_size        16k;     
  33.     proxy_buffers            4 64k;     
  34.     proxy_busy_buffers_size 128k;     
  35.     proxy_temp_file_write_size 128k;      
  36.       
  37.     gzip on;     
  38.     gzip_min_length  1k;     
  39.     gzip_buffers 4 16k;     
  40.     gzip_http_version 1.1;     
  41.     gzip_comp_level 2;     
  42.     gzip_types text/plain application/x-javascript text/css application/xml;     
  43.     gzip_vary on;  
  44.   
  45.     #注:images_temp和images_cache指定的路径必须在同一分区  
  46.     proxy_temp_path   :/usr/local/nginx-0.8.32/html/SD/images_temp;  
  47.     #设置Web缓存区名称为cache_one,内存缓存空间大小为200MB,1天没有被访问的内容自动清除,硬盘缓存空间大小为30GB。  
  48.     Proxy_cache_path  :/usr/local/nginx-0.8.32/html/SD/images_cache  levels=1:2   keys_zone=cache_one:200m inactive=1d max_size=30g;  
  49.   
  50.     server {  
  51.         listen       80;  
  52.         server_name  192.168.0.146;  
  53.         location / {  
  54.                 proxy_cache cache_one;  
  55.                 #对不同的HTTP状态码设置不同的缓存时间  
  56.                 proxy_cache_valid  200 304 12h;  
  57.                 #以域名、URI、参数组合成Web缓存的Key值,Nginx根据Key值哈希,存储缓存内容到二级缓存目录内  
  58.                 proxy_cache_key $host$uri$is_args$args;  
  59.                 proxy_set_header Host  $host;  
  60.                 proxy_set_header X-Forwarded-For  $remote_addr;  
  61.                 proxy_pass http://192.168.0.146:8080;  
  62.             log_format cache '***$time_local '  '***$upstream_cache_status '  '***Cache-Control: $upstream_http_cache_control ' '***Expires: $upstream_http_expires ' '***"$request" ($status) ' '***"$http_user_agent" ';  
  63.             access_log  /usr/local/nginx-0.8.32/logs/cache.log cache;  
  64.                 expires      1d;  
  65.                 }  
  66.   
  67.             #用于清除缓存,假设一个URL为http://192.168.8.42/test.txt,通过访问http://192.168.8.42/purge/test.txt就可以清除该URL的缓存。  
  68.     location ~ /purge(/.*) {  
  69.                 #设置只允许指定的IP或IP段才可以清除URL缓存。  
  70.             allow       127.0.0.1;  
  71.             allow       192.168.0.0/16;  
  72.             deny    all;  
  73.             proxy_cache_purge    cache_one   $host$1$is_args$args;  
  74.     }   
  75.   
  76.             #扩展名以.php、.jsp、.cgi结尾的动态应用程序不缓存。  
  77.     location ~ .*\.(php|jsp|cgi)?$ {  
  78.                 proxy_set_header Host  $host;  
  79.                 proxy_set_header X-Forwarded-For  $remote_addr;  
  80.                 proxy_pass http://192.168.0.146:8080;  
  81.         }  
  82.         access_log  off;  
  83.     }  
  84.   
  85.     server{  
  86.     listen 8080;   
  87.             server_name 192.168.33.243;   
  88.           
  89.     location / {   
  90.         root /usr/local/webapp;   
  91.     }   
  92.         access_log off;  
  93.      }  


http://hermit-macx.iteye.com/blog/1697375

阅读(10255) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~