基于nginx 动态 URL反向代理的实现

news2025/4/15 12:42:33

背景:

        我们在项目中在这样一个场景,用户需要使用固定的软件资源,这些资源是以服务器或者以容器形式存在的。

        资源以webAPI方式在内网向外提供接口,资源分类多种类型,每种类型的资源程序和Wapi参数都一样。这些资源部属完成后使用IP+端口进行区分。如下表所示

     

技术分析:

经过调研分析,发现Nginx 可以进行么向代理,代理后可以进行调度到内部的数据

技术验证:

1.使用静态方式在配置文件中直接写入

如下:

server {
        listen        22280;
        server_name  localhost;
        root   "D:/dist";
        location / {
            index index.php index.html error/index.html;
            error_page 400 /error/400.html;
            error_page 403 /error/403.html;
            error_page 404 /error/404.html;
            error_page 500 /error/500.html;
            error_page 501 /error/501.html;
            error_page 502 /error/502.html;
            error_page 503 /error/503.html;
            error_page 504 /error/504.html;
            error_page 505 /error/505.html;
            error_page 506 /error/506.html;
            error_page 507 /error/507.html;
            error_page 509 /error/509.html;
            error_page 510 /error/510.html;
            #include D:/Git/111/nginx.htaccess;
            autoindex  off;
			try_files $uri $uri/ @router; #需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
			index  index.html index.htm;
        }
		#反向代理 
		location /r1/ {     
			proxy_pass http://192.168.1.88:888/;            
        }
				location /r2/ {     
			proxy_pass http://192.168.1.88:887/;            
        }
				location /i1/ {     
			proxy_pass http://192.168.1.89:3333/;            
        }
				location /i2/ {     
			proxy_pass http://192.168.1.90:3333/;            
        }
 
  #对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
  #因此需要rewrite到index.html中,然后交给路由在处理请求资源
		location @router {
				rewrite ^.*$ /index.html last;
			}
        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}

使用此方式可以达到所需效果,但如果资源变化需要手动调整Nginx的配置文件。因此考虑有没有一种办法可以做到动态转发呢?

问题难点:

1.资源需要一定的规律性

2.nginx动态转发功能技术上需要进行预研,明确是否可行

实现过程:

1.确定方案

方案里我们准备采用 固定内容+端口号的形式来进行处理,在此之前我们需要把服务用K8S映射到

同一IP或者同一规则的内容上。并且对URL进行了定义 /rs/(\d+)/实际API  的形式进行调用

2.方案实现

我们假定所有的 k8s 把所有的服务地址都映射到了 192.168.1.88上,仅端口不同,使用不同的端口就可以调度到不同的服务。

部分配置如下:

		location /rs/(\d.+)/ {     
			proxy_pass http://localhost:$/;            
        }

运行报错 http 500

500 Internal Server Error
nginx/1.15.11
问题处理:
2024/03/22 17:07:35 [error] 5072#34752: *264 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:07:35 [error] 5072#34752: *265 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:08:15 [error] 5072#34752: *268 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:08:16 [error] 5072#34752: *269 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:08:16 [error] 5072#34752: *270 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:08:17 [error] 5072#34752: *271 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:24 [error] 5072#34752: *273 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:24 [error] 5072#34752: *274 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:25 [error] 5072#34752: *275 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:26 [error] 5072#34752: *276 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:27 [error] 5072#34752: *277 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:27 [error] 5072#34752: *278 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:35 [error] 5072#34752: *283 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:36 [error] 5072#34752: *284 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:36 [error] 5072#34752: *285 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:37 [error] 5072#34752: *286 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:38 [error] 5072#34752: *287 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:09:38 [error] 5072#34752: *288 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280"
2024/03/22 17:10:00 [error] 5072#34752: *279 upstream prematurely closed connection while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/api/sysAuth/index.html HTTP/1.1", upstream: "http://192.168.27.51:60000/", host: "127.0.0.1:280"
2024/03/22 17:10:00 [error] 5072#34752: *279 rewrite or internal redirection cycle while processing "/index.html", client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/api/sysAuth/index.html HTTP/1.1", upstream: "http://192.168.27.51:60000/", host: "127.0.0.1:280"
2024/03/22 17:10:01 [error] 5072#34752: *280 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280", referrer: "http://127.0.0.1:280/uuu/60000/api/sysAuth/index.html"
2024/03/22 17:11:05 [error] 5072#34752: *290 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/api/sysAuth/index.html HTTP/1.1", upstream: "http://192.168.27.51:60000/", host: "127.0.0.1:280"
2024/03/22 17:11:05 [error] 5072#34752: *290 rewrite or internal redirection cycle while processing "/index.html", client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/api/sysAuth/index.html HTTP/1.1", upstream: "http://192.168.27.51:60000/", host: "127.0.0.1:280"
2024/03/22 17:11:05 [error] 5072#34752: *293 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "127.0.0.1:280", referrer: "http://127.0.0.1:280/uuu/60000/api/sysAuth/index.html"
2024/03/22 17:14:18 [error] 8748#17732: *1 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/index.html HTTP/1.1", upstream: "http://192.168.27.51:60000/uuu/60000/index.html", host: "localhost:280"
2024/03/22 17:14:18 [error] 8748#17732: *1 rewrite or internal redirection cycle while processing "/index.html", client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/index.html HTTP/1.1", upstream: "http://192.168.27.51:60000/uuu/60000/index.html", host: "localhost:280"
2024/03/22 17:14:19 [error] 8748#17732: *5 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/uuu/60000/index.html"
2024/03/22 17:15:59 [error] 12116#31400: *4 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/aaaa HTTP/1.1", upstream: "http://192.168.27.51:60000/", host: "localhost:280"
2024/03/22 17:15:59 [error] 12116#31400: *4 rewrite or internal redirection cycle while processing "/index.html", client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/aaaa HTTP/1.1", upstream: "http://192.168.27.51:60000/", host: "localhost:280"
2024/03/22 17:15:59 [error] 12116#31400: *7 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/uuu/60000/aaaa"
2024/03/22 17:20:20 [error] 33904#20644: *1 upstream timed out (10060: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond) while reading response header from upstream, client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/api/sysAuth/captcha HTTP/1.1", upstream: "http://192.168.27.51:60000/", host: "localhost:280"
2024/03/22 17:20:20 [error] 33904#20644: *1 rewrite or internal redirection cycle while processing "/index.html", client: 127.0.0.1, server: localhost, request: "GET /uuu/60000/api/sysAuth/captcha HTTP/1.1", upstream: "http://192.168.27.51:60000/", host: "localhost:280"
2024/03/22 17:20:20 [error] 33904#20644: *4 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/uuu/60000/api/sysAuth/captcha"
2024/03/22 17:24:31 [error] 41040#27804: *2 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /favicon.ico HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/uuu/5257/api/sysAuth/captcha"
2024/03/22 17:24:35 [error] 41040#27804: *4 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /_framework/aspnetcore-browser-refresh.js HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/uuu/5257/index.html"
2024/03/22 17:24:35 [error] 41040#27804: *11 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /index-mini-profiler/includes.min.js?v=4.3.8+1120572909 HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/uuu/5257/index.html"
2024/03/22 17:24:35 [error] 41040#27804: *12 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /_vs/browserLink HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/uuu/5257/index.html"
2024/03/22 17:24:35 [error] 41040#27804: *13 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /swagger/%E5%85%AC%E5%85%B1%E6%9C%8D%E5%8A%A1/swagger.json HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/uuu/5257/index.html"
2024/03/22 17:35:40 [error] 41512#41416: *8 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /_framework/aspnetcore-browser-refresh.js HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/area/5257/index.html"
2024/03/22 17:35:40 [error] 41512#41416: *10 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /_vs/browserLink HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/area/5257/index.html"
2024/03/22 17:35:40 [error] 41512#41416: *9 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /index-mini-profiler/includes.min.js?v=4.3.8+1120572909 HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/area/5257/index.html"
2024/03/22 17:35:40 [error] 41512#41416: *2 rewrite or internal redirection cycle while redirect to named location "@router", client: 127.0.0.1, server: localhost, request: "GET /swagger/%E5%85%AC%E5%85%B1%E6%9C%8D%E5%8A%A1/swagger.json HTTP/1.1", host: "localhost:280", referrer: "http://localhost:280/area/5257/index.html"

通过日志发现存在循环引用之类的

考虑使用URL重写改变下,路径。再使用proxy_pass反向代理。尝试修改nginx并进行修改。

问题解决
location ~ ^/rs/(\d.+)/{
			rewrite ^/rs/(\d+)/(.*)$ /$2 break;
			proxy_pass http://192.168.1.88:$1;  
        }

最终结果能够正常转发到指定端口,并且nginx 也不用修改配置,实现了动态端口反向代理。

在这个过程中我发现要实现/dir/port/xxx 这种进行反向代理必须与url重写结合使用。不然会报404.

完整能够成功运行的配置nginx.conf如下

server {
        listen        22280;
        server_name  localhost;
        root   "D:/dist";
        location / {
            index index.php index.html error/index.html;
            error_page 400 /error/400.html;
            error_page 403 /error/403.html;
            error_page 404 /error/404.html;
            error_page 500 /error/500.html;
            error_page 501 /error/501.html;
            error_page 502 /error/502.html;
            error_page 503 /error/503.html;
            error_page 504 /error/504.html;
            error_page 505 /error/505.html;
            error_page 506 /error/506.html;
            error_page 507 /error/507.html;
            error_page 509 /error/509.html;
            error_page 510 /error/510.html;
            #include D:/Git/111/nginx.htaccess;
            autoindex  off;
			try_files $uri $uri/ @router; #需要指向下面的@router否则会出现vue的路由在nginx中刷新出现404
			index  index.html index.htm;
        }
		#反向代理 
		location ~ ^/rs/(\d.+)/{
			rewrite ^/rs/(\d+)/(.*)$ /$2 break;
			proxy_pass http://192.168.1.88:$1;  
        }
 
  #对应上面的@router,主要原因是路由的路径资源并不是一个真实的路径,所以无法找到具体的文件
  #因此需要rewrite到index.html中,然后交给路由在处理请求资源
		location @router {
				rewrite ^.*$ /index.html last;
			}
        location ~ \.php(.*)$ {
            fastcgi_pass   127.0.0.1:9000;
            fastcgi_index  index.php;
            fastcgi_split_path_info  ^((?U).+\.php)(/?.+)$;
            fastcgi_param  SCRIPT_FILENAME  $document_root$fastcgi_script_name;
            fastcgi_param  PATH_INFO  $fastcgi_path_info;
            fastcgi_param  PATH_TRANSLATED  $document_root$fastcgi_path_info;
            include        fastcgi_params;
        }
}

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/1547165.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

域名交易系统源码 无需授权即可正常使用,附带后台功能

域名交易系统已测试可正常使用免授权带后台 源码下载:https://download.csdn.net/download/m0_66047725/88949686 更多资源下载:关注我。

Unity 打包真机脚本丢失的问题

记录Bug Bug详情分析解决方案附录 Bug详情 项目中导入了UI Particle的Package,用于处理特效层级 unity 运行效果正常,打包真机后运行时发现特效并没有正确显示,真机Log如下图 需要接入查看真机Log工具的点这里 查看图中Log发现对应的Prefab上挂载的脚本…

uniApp中使用小程序XR-Frame创建3D场景(2)加载模型

上篇文章讲述了如何将XR-Frame作为子组件集成到uniApp中使用,只完成了简单的环境搭建,这篇文章讲解如何加载3D模型。 1 加入模型加载标签 在XR-Frame框架中,加载资源都是在wxml文件的标签中实现的。下面是wxml中完整的代码 index.wxml &l…

github vscode 笔记

目录 前言1. 新建代码库2. 下载代码到本地3. 更新代码并上传到github 前言 github方便多人协作维护代码。该笔记记录了下面三个过程: 在github上新建代码库,下载代码到本地,将更新代码并上传到github 1. 新建代码库 2. 下载代码到本地 链…

本地GPU调用失败问题解决1

一:发现问题 1、电脑环境参数: OMEN by Gaming Laptop Windows 11 家庭中文版 2th Gen Intel(R) Core(TM) i9-12900H 2.50 GHz NVIDIA GeForce RTX 3060 Laptop GPU 显存6G PyCharm 2023.1.1(Professional Edition) 2、PyCharm中检测GPU&#x…

web自动化测试系列-selenium的运行原理和常用方法介绍(二)

目录 1.selenium的运行原理 2.常用方法介绍 接上文 :web自动化测试系列-selenium的安装和运行(一)-CSDN博客 在上文中我们编写了一段简单的代码 ,可以驱动浏览器访问百度并搜索关键字 。这里我们再把这段代码再拿来加以说明 。 # 1. 导包 from selen…

Linux Tomcat的服务器如何查看接口请求方式?

问题描述 最近在和安卓开发对接接口,遇到一个接口总是报405错误,有对接经验的开发应该都知道是请求方式不对,假如接口定义为POST请求的,但是客户端却用GET请求,这时候就会报这个错误。Android客户端那边使用xUtils框架…

【AutoML】一个用于图像、文本、时间序列和表格数据的AutoML

一个用于图像、文本、时间序列和表格数据的AutoML AutoGluon介绍安装AutoGluon快速上手 参考资料 AutoGluon自动化机器学习任务,使您能够在应用程序中轻松实现强大的预测性能。只需几行代码就可以训练和部署有关图像,文本,时间序列和表格数据…

搭建Spark单机版环境

在搭建Spark单机版环境的实战中,首先确保已经安装并配置好了JDK。然后,从群共享下载Spark安装包,并将其上传至目标主机的/opt目录。接着,解压Spark安装包至/usr/local目录,并配置Spark的环境变量,以确保系统…

计算机网络:物理层 - 编码与调制

计算机网络:物理层 - 编码与调制 基本概念编码不归零制编码归零制编码曼彻斯特编码差分曼彻斯特编码 调制调幅调频调相混合调制 基本概念 在计算机网络中,计算机需要处理和传输用户的文字、图片、音频和视频,他们可以统称为消息数据&#xf…

C#学习笔记3:Windows窗口计时器

今日继续我的C#学习之路,今日学习自己制作一个Windows窗口计时器程序: 文章提供源码解释、步骤操作、整体项目工程下载 完成后的效果大致如下:(可选择秒数,有进度条,开始计时按钮等) &#xf…

一周学会Django5 Python Web开发-Django5模型定义

锋哥原创的Python Web开发 Django5视频教程: 2024版 Django5 Python web开发 视频教程(无废话版) 玩命更新中~_哔哩哔哩_bilibili2024版 Django5 Python web开发 视频教程(无废话版) 玩命更新中~共计41条视频,包括:2024版 Django5 Python we…

并发VS并行

参考文章 面试必考的:并发和并行有什么区别? 并发:一个人同时做多件事(射击游戏队友抢装备) 并行:多人同时处理同一件事(射击游戏敌人同时射击对方)

业务服务:xss攻击

文章目录 前言一、使用注解预防1. 添加依赖2. 自定义注解3. 自定义校验逻辑4. 使用 二、使用过滤器1. 添加配置2. 创建配置类3. 创建过滤器4. 创建过滤器类5. 使用 前言 xss攻击时安全领域中非常常见的一种方法,保证我们的系统安全是非常重要的 xss攻击简单来说就…

酷开科技:OTT领域的璀璨明珠

在广袤的科技海洋中,酷开科技犹如一颗璀璨的明珠,以其独特的魅力和卓越的实力,引领着OTT领域的发展。自2014年前后,彩电业遭遇三十年来首次的销量滑坡,整个行业陷入了“寒冬”。在这个艰难的时刻,酷开科技却…

pure-admin

vue-pure-admin: 🔥 全面ESMVue3ViteElement-PlusTypeScript编写的一款后台管理系统(兼容移动端)

GBU3510-ASEMI开关电源整流桥GBU3510

编辑:ll GBU3510-ASEMI开关电源整流桥GBU3510 型号:GBU3510 品牌:ASEMI 封装:GBU-4 平均正向整流电流(Id):35A 最大反向击穿电压(VRM):1000V 产品引线…

【jenkins+cmake+svn管理c++项目】windows修改jenkins的工作目录

jenkins默认的存放源码的workspace是: C:\Users\用户\AppData\Local\Jenkins\.jenkins\workspace。由于jenkins会拉取大量的源代码以及编译生成一些文件,我希望我能自己指定目录作为它的工作空间,放在这里显然不太合适。 那么修改目录的方式有…

windows允许指定IP段访问本地端口

虚拟机内部应用有时候需要访问windows的一些端口,例如数据库或Redis等,默认情况下,需关闭windows上的防火墙才可正常访问。本文通过在防火墙设置允许指定IP段进行访问来处理,不用每次操作都关闭防火墙。 入站规则-》新建规则 完成…

Memcached分布式内存对象数据库

一 Memcached 概念 Memcached 是一个高性能的分布式内存对象缓存系统,用于动态 Web 应用以减轻数据库负载。它通过在内存中缓存数据和对象来减少读取数据库的次数,从而提高动态、数据库驱动网站的速度。 二 在架构中的位置 Memcached 处于前端或中间件后…