文件配置
proxy_temp_path /data/cache1/proxy_temp;
proxy_cache_path /data/cache1/proxy_cache levels=1:2 keys_zone=tmp_cache:200m inactive=10000d max_size=2G;
#设置Web缓存区名称为tmp_cache,内存缓存空间大小为200MB,1000天没有被访问的内容自动清除,硬盘缓存空间大小为2G。
location / {
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 180;
proxy_send_timeout 180;
proxy_read_timeout 180;
proxy_buffer_size 128k;
proxy_buffers 4 128k;
proxy_busy_buffers_size 128k;
proxy_temp_file_write_size 128k;
proxy_cache tmp_cache;
proxy_cache_valid 200 304 1m;
proxy_cache_valid 404 1m;
proxy_cache_key $uri$is_args$args; #使用域名、URI、参数组合Web缓存的Key值,Nginx根据Key值进行哈希计算,存储缓存内容到二级缓存目录内
add_header Nginx-Cache "$upstream_cache_status";
proxy_pass
}
wget 第一次访问反向代理服务器
[root@B ~]# wget -SO /dev/null -e http_proxy=127.0.0.1
--2014-06-29 21:36:02--
Connecting to 127.0.0.1:80... connected.
Proxy request sent, awaiting response...
HTTP/1.1 200 OK
Server: nginx/1.0.9
Date: Sun, 29 Jun 2014 13:36:03 GMT
Content-Type: text/html
Connection: close
Content-Length: 10
Last-Modified: Sat, 29 Mar 2014 18:23:44 GMT
Accept-Ranges: bytes
Nginx-Cache: EXPIRED
Length: 10 [text/html]
Saving to: `/dev/null'
100%[===========================================================================================================================>] 10 --.-K/s in 0s
2014-06-29 21:36:03 (376 KB/s) - `/dev/null' saved [10/10]
[root@B ~]#
wget 第二次访问反向代理服务器
[root@B ~]# wget -SO /dev/null -e http_proxy=127.0.0.1
--2014-06-29 21:37:01--
Connecting to 127.0.0.1:80... connected.
Proxy request sent, awaiting response...
HTTP/1.1 200 OK
Server: nginx/1.0.9
Date: Sun, 29 Jun 2014 13:37:01 GMT
Content-Type: text/html
Connection: close
Content-Length: 10
Last-Modified: Sat, 29 Mar 2014 18:23:44 GMT
Nginx-Cache: HIT
Accept-Ranges: bytes
Length: 10 [text/html]
Saving to: `/dev/null'
100%[===========================================================================================================================>] 10 --.-K/s in 0s
2014-06-29 21:37:01 (66.0 KB/s) - `/dev/null' saved [10/10]
access.log日志
127.0.0.1 - - [29/Jun/2014:21:36:03 +0800] "GET HTTP/1.0" 200 10 "-" "Wget/1.11.4 Red Hat modified" "-" "EXPIRED"
127.0.0.1 - - [29/Jun/2014:21:37:01 +0800] "GET HTTP/1.0" 200 10 "-" "Wget/1.11.4 Red Hat modified" "-" "HIT"
阅读(509) | 评论(0) | 转发(0) |