Nginx 反向代理并缓存及缓存清除
Nginx 反向代理并缓存及缓存清除
原文地址:http://www.cnblogs.com/caoguo/p/5012447.html
一. Nginx 配置
#user nobody;
worker_processes ; #error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info; #pid logs/nginx.pid; events {
worker_connections ;
} http {
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"'
'$upstream_addr $upstream_status $request_time $upstream_response_time'; access_log /var/log/nginx/access.log main;
error_log /var/log/nginx/error.log; server_tokens off;
include mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
client_max_body_size 10m;
client_body_buffer_size 128k; proxy_connect_timeout ;
proxy_send_timeout ;
proxy_read_timeout ;
proxy_buffer_size 64k;
proxy_buffers 512k;
proxy_busy_buffers_size 512k;
proxy_temp_file_write_size 512k;
proxy_temp_path /data/nginx/proxy_temp;
proxy_cache_path /data/nginx/proxy_cache levels=: keys_zone=cache_one:2000m inactive=3d max_size=500g; 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; gzip on;
gzip_min_length 1k;
gzip_buffers 16k;
gzip_http_version 1.1;
gzip_comp_level ;
gzip_types text/plain application/x-javascript text/css application/xml;
gzip_vary on; upstream go {
server www.cnblogs.com: weight=;
#server 42.121.252.58: weight=;
} server { listen 192.168.55.133:;
#server_name www.cnblogs.com;
access_log /var/log/nginx/go.access.log main;
error_log /var/log/nginx/go.error.log error; location / {
proxy_cache cache_one;
#proxy_cache_valid 2h;
#proxy_cache_valid any 2h;
#expires 1d;
add_header X-Cache $upstream_cache_status;
proxy_pass http://go;
proxy_cache_key $uri$is_args$args;
} location ~ /purge(/.*) {
allow 127.0.0.1;
allow 192.168.55.0/;
deny all;
proxy_cache_purge cache_one $$is_args$args;
} }
}
二. 测试
1.首次访问

2.刷新一次,也就是第二次访问

3.缓存清理

Nginx 反向代理并缓存及缓存清除的更多相关文章
- Nginx反向代理 负载均衡 页面缓存 URL重写及读写分离
大纲 一.前言 二.环境准备 三.安装与配置Nginx 四.Nginx之反向代理 五.Nginx之负载均衡 六.Nginx之页面缓存 七.Nginx之URL重写 八.Nginx之读写分离 注,操作系统 ...
- nginx反向代理+缓存开启+url重写+负载均衡(带健康探测)的部署记录
在日常运维工作中,运维人员会时常使用到nginx的反向代理,负载均衡以及缓存等功能来优化web服务性能. 废话不多说,下面对测试环境下的nginx反向代理+缓存开启+url重写+负载均衡(带健康探测) ...
- nginx反向代理缓存服务器的构建
一:代理服务可简单的分为正向代理和反向代理: 正向代理:用于代理内部网络对Internet的连接请求(如VPN/NAT),客户端指定代理服务器,并将本来要直接发送给目标Web服务器的HTTP请求先发送 ...
- Nginx 反向代理、负载均衡、页面缓存、URL重写及读写分离详解
转载:http://freeloda.blog.51cto.com/2033581/1288553 大纲 一.前言 二.环境准备 三.安装与配置Nginx 四.Nginx之反向代理 五.Nginx之负 ...
- Nginx反向代理、负载均衡、页面缓存、URL重写及读写分离详解
大纲 一.前言 二.环境准备 三.安装与配置Nginx 四.Nginx之反向代理 五.Nginx之负载均衡 六.Nginx之页面缓存 七.Nginx之URL重写 八.Nginx之读写分离 注,操作系统 ...
- Nginx 反向代理、负载均衡、页面缓存、URL重写以及读写分离
1.环境准备 前端Nginx:10.160.65.44 后端WEB服务器两台:10.160.65.49/10.160.65.50 2.安装Nginx: 下载nginx-1.9.15.tar.gz,放置 ...
- Nginx 反向代理、负载均衡、页面缓存、URL重写、读写分离及简单双机热备详解
大纲 一.前言 二.环境准备 三.安装与配置Nginx (windows下nginx安装.配置与使用) 四.Nginx之反向代理 五.Nginx之负载均衡 (负载均衡算法:nginx负载算法 up ...
- [转载]Nginx 反向代理、负载均衡、页面缓存、URL重写及读写分离详解
大纲 一.前言 二.环境准备 三.安装与配置Nginx 四.Nginx之反向代理 五.Nginx之负载均衡 六.Nginx之页面缓存 七.Nginx之URL重写 八.Nginx之读写分离 注,操作系统 ...
- 正向代理 forward proxy、反向代理 reverse proxy、透明代理 transparent proxy nginx反向代理原理和配置讲解 防止外部客户机获取内部内容服务器的重定向 URL 缓存命中
[大型网站技术实践]初级篇:借助Nginx搭建反向代理服务器 - Edison Chou - 博客园http://www.cnblogs.com/edisonchou/p/4126742.html 图 ...
随机推荐
- SiteMesh2-标签库
SiteMesh包括两大标签库. 一.Decorator Tags:被用于建立装饰器页面. 1.<decorator:head/> 插入原始页面(被包装页面)的head标签中的内容(不包 ...
- VM Workstation 虚拟机安装Ghost XP教程
1 工具和软件准备 VM Workstation虚拟机软件(必须) http://pan.baidu.com/share/link?shareid=304385&uk=637999033 ...
- BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第12章节--SP 2013中远程Event Receivers
BEGINNING SHAREPOINT® 2013 DEVELOPMENT 第12章节--SP 2013中远程Event Receivers 本章中,你讲学到: 了解远程evernt ...
- svg 虚线
用 svg 元素画出一条直线很简单,用 line 等元素都可以,可是画虚线的话,就需要一个属性: stroke-dasharray: 1 2; 画1px 空2px (长这个样子) stroke-da ...
- NoSQL 世界交换数据的事实标准
https://www.elastic.co/guide/cn/elasticsearch/guide/current/data-in-data-out.html An object is a lan ...
- Getting console.log output with Selenium Python API bindings
持久化存储 Getting console.log output from Chrome with Selenium Python API bindings - Stack Overflow http ...
- ios11--UIButton
// // ViewController.m // 02-UIButton(在代码中使用) // #import "ViewController.h" @interface Vie ...
- Codeforces Round #142 (Div. 2)B. T-primes
B. T-primes time limit per test 2 seconds memory limit per test 256 megabytes input standard input o ...
- Quartz在.Net网站中的使用方法(附Demo)
现在做一个B/S项目需要用到计划任务,本来想自定写一个的,写了几句,突然想看看网上有没有现成可以用的.结果在苦寻之下找到了Quartz这个组件.看过之后感觉还不错.决定用它实现计划任务了.再找找看有没 ...
- 【模板】 倍增lca
虽然很基础,但是还是复习了一下,毕竟比树剖好写... 代码: #include<iostream> #include<cstdio> #include<cmath> ...