1.参数说明
proxy_set_header 重新封装包头,和日志格式有关系,定义在location里面 proxy_cache 是否开启nginx缓存,定义在location里面 proxy_cache_vaild 对于http的什么状态码进行缓存以及缓存的时间,定义在location里面 proxy_cache_path 缓存的路径,定义在server外面,location定义在server里面 add_header 添加包头,定义在location里面
2.举例说明
proxy_cache_path /data/nginx/cache levels=1:2:1 keys_zone=one:10m;缓存的文件在哪儿,缓存文件的属性; proxy_cache_valid 200 302 10m; 对于202 302状态码缓存10分钟。 proxy_set_header Host $host:80;proxy_set_header X-Forward-For $remote_addr; add_header X-Cache $upstream_cache_status; add_header X-Via $server_addr; add_header X-Cache "$upstream_cache_status from $remote_addr"
转载于:https://blog.51cto.com/yujianglei/1560541