Nginx 反向代理并缓存及缓存清除技术

  Nginx 反向代理并缓存及缓存清除技术

  

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
#user nobody;
worker_processes 1;
  
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
  
#pid    logs/nginx.pid;
  
  
events {
  worker_connections 1024;
}
  
  
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 300;
  proxy_send_timeout 300;
  proxy_read_timeout 300;
  proxy_buffer_size 64k;
  proxy_buffers 4 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=1:2 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 4 16k;
  gzip_http_version 1.1;
  gzip_comp_level 2;
  gzip_types text/plain application/x-javascript text/css application/xml;
  gzip_vary on;
  
  upstream go {
    server www.sdfymj.com:80 weight=4;
    #server 42.121.252.58:80 weight=4;
  }
  
  server {
  
      listen  192.168.55.133:80;
      #server_name www.sdfymj.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 200 304 301 302 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/24;
        deny        all;
        proxy_cache_purge cache_one $1$is_args$args;
    }
  
  }
}

  

posted @   圆柱模板  阅读(784)  评论(0编辑  收藏  举报
编辑推荐:
· 开发者必知的日志记录最佳实践
· SQL Server 2025 AI相关能力初探
· Linux系列:如何用 C#调用 C方法造成内存泄露
· AI与.NET技术实操系列(二):开始使用ML.NET
· 记一次.NET内存居高不下排查解决与启示
阅读排行:
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 开源Multi-agent AI智能体框架aevatar.ai,欢迎大家贡献代码
· Manus重磅发布:全球首款通用AI代理技术深度解析与实战指南
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· AI技术革命,工作效率10个最佳AI工具
历史上的今天:
2018-08-06 destoon自定义函数获取地区名称
2018-08-06 dt开发之-自定义函数获取分类名称
2018-08-06 dt二次开发之-地区链接伪静态标签用法
2018-08-06 DT二次开发之-采购页面加入好看的倒计时
2018-08-06 DT二次开发之-资讯列表中调用 TAG 关键词
2018-08-06 DT系统中tag如何使用like与%来进行模糊查询
2018-08-06 如何防护DDOS攻击策略
点击右上角即可分享
微信分享提示