用的军哥的LNMP
参照张宴的:使用Nginx的proxy_cache缓存功能取代Squid[原创](http://blog.s135.com/nginx_cache/4/1/)
现在/usr/local/nginx/sbin/nginx -t显示OK,缓存可以生成,但是清理缓存的时候访问

的时候显示的不是Successful purge,而是直接显示地址,其他格式的静态文件如js直接白板
配置文件如下
nginx.conf- user www www;

  • - worker_processes 1;
  • - error_log /home/wwwlogs/nginx_error.log crit;
  • - pid /usr/local/nginx/logs/nginx.pid;
  • - #Specifies the value for maximum file descriptors that can be opened by this process.
  • worker_rlimit_nofile 51200;
  • - events
  • {
  • use epoll;
  • worker_connections 51200;
  • }
  • - http
  • {
  • include mime.types;
  • default_type application/octet-stream;
  • - server_names_hash_bucket_size 128;
  • client_header_buffer_size 32k;
  • large_client_header_buffers 4 32k;
  • - sendfile on;
  • tcp_nopush on;
  • - keepalive_timeout 120;
  • - tcp_nodelay on;
  • - gzip on;
  • gzip_min_length 1k;
  • gzip_buffers 4 16k;
  • gzip_http_version 1.1;
  • gzip_comp_level 2;
  • gzip_types text/plain application/x-javascript text/css application/xml;
  • gzip_vary on;
  • - proxy_temp_path /usr/local/nginx/proxy_temp;
  • proxy_cache_path /usr/local/nginx/proxy_cache levels=1:2 keys_zone=cache_pool:60m inactive=1d max_size=8g;
  • - #limit_zone crawler $binary_remote_addr 10m;
  • - server
  • {
  • listen 80;
  • server_name a.b.c.d;
  • index index.html index.htm index.php;
  • root /home/wwwroot;
  • - location ~ .*\.(php|php5)?$
  • {
  • fastcgi_pass unix:/tmp/php-cgi.sock;
  • fastcgi_index index.php;
  • include fcgi.conf;
  • }
  • - location /status {
  • stub_status on;
  • access_log off;
  • }
  • - location ~ .*\.(gif|jpg|jpeg|png|bmp|swf)$
  • {
  • expires 30d;
  • }
  • - location ~ .*\.(js|css)?$
  • {
  • expires 12h;
  • }
  • - log_format access '$remote_addr - $remote_user [$time_local] "$request" '
  • '$status $body_bytes_sent "$http_referer" '
  • '"$http_user_agent" $http_x_forwarded_for';
  • access_log /home/wwwlogs/access.log access;
  • }
  • include vhost/*.conf;
  • }复制代码proxy-baidu.com.conf- server
  • {
  • listen 80;
  • server_name baidu.com www.baidu.com;
  • index index.html index.htm;
  • if ($host != 'www.baidu.com')
  • {rewrite ^/(.*)$ http://www.baidu.com/$1 permanent;}
  • root /home/wwwroot/www.proxy-baidu.com;
  • - location / {
  • proxy_pass http://www.baidu.com;
  • proxy_redirect off ;
  • proxy_set_header Host $host;
  • proxy_set_header X-Real-IP $remote_addr;
  • proxy_set_header REMOTE-HOST $remote_addr;
  • proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  • - client_max_body_size 300m;
  • client_body_buffer_size 512k;
  • - proxy_connect_timeout 120;
  • proxy_read_timeout 120;
  • proxy_send_timeout 120;
  • proxy_buffer_size 256k;
  • proxy_buffers 4 256k;
  • proxy_busy_buffers_size 256k;
  • proxy_temp_file_write_size 256k;
  • proxy_max_temp_file_size 128m;
  • - proxy_cache cache_pool;
  • proxy_cache_key $host$uri$is_args$args;
  • proxy_cache_valid 200 301 302 304 1h;
  • expires 1d;
  • }
  • - location ~ .*\.(php|jsp|cgi)?$
  • {
  • proxy_set_header Host $host;
  • proxy_set_header X-Forwarded-For $remote_addr;
  • proxy_pass http://www.baidu.com;
  • }
  • - location ~ /purge(/.*)
  • {
  • allow 127.0.0.1;
  • allow 1.2.3.4;
  • deny all;
  • proxy_cache_purge cache_pool $host$1$is_args$args;
  • }
  • - access_log off;
  • }复制代码upstream.conf- upstream www.baidu.com {
  • server 225.225.225.225:80;
  • }复制代码找了半天不知道哪有问题,可能是key?求指点迷津

![](016.gif)