nginx 实现cache

cache 192.168.1.142

源192.168.1.148

在142配置

vi /etc/nginx/nginx.conf

worker_processes 2;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;

proxy_cache_path /data/webcache levels=1:2 keys_zone=servers:20m max_size=1g;
server {
listen 80;
server_name _;
index index.html;
add_header X-Via $server_addr;
add_header X-Cache $upstream_cache_status;

location / {
proxy_pass http://192.168.1.148:80;
proxy_set_header X-Real-IP $remote_addr;
proxy_cache servers;
proxy_cache_valid 200 5m;
}
}

}

 

 

mkdir -p /data/webcache

chown www:www /data/ -R -f

chcon -R -t httpd_sys_rw_content_t /data/webcache/

systemctl restart nginx.service

 

 

访问192.168.1.142 测试

看/data/webserver中

 

posted @ 2017-02-09 17:49  *奥特*  阅读(179)  评论(0)    收藏  举报