~]# vim /apps/nginx/conf/conf.d/home.conf
server {
listen 80;
server_name www.rookie.com;
location / {
proxy_pass http://192.168.10.103:80/;
}
}
server {
listen 80;
server_name www.rookie.com;
location / {
index index.html index.php;
root /data/nginx/html/home;
}
location /web {
proxy_pass http://192.168.10.104:80/; # 注意后面的"/"
}
}
~]# vim /apps/nginx/conf/nginx.conf
proxy_cache_path /data/nginx/proxycache
levels=1:1:1
keys_zone=proxycache:20m
inactive=120s
max_size=1g
# 配置在 http 段
~]# vim /apps/nginx/conf/conf.d/home.conf
location /home { # 要缓存的 URL 或者放在 server 配置项对所有 URL 都进行缓存
proxy_pass http://192.168.10.104:80/;
proxy_set_header clientip $remote_addr;
proxy_cache proxycache;
proxy_cache_key $request_uri;
proxy_cache_valid 200 302 301 1h;
proxy_cache_valid any 1m;
}
网友评论