96SEO 2026-02-23 11:51 22
在docker/docker-compose.yml中添加nginx服务块。

…
在docker/docker-compose.yml中添加nginx服务块。
./nginx/conf/nginx.conf:/etc/nginx/nginx.conf-
./nginx/conf/conf.d/default.conf:/etc/nginx/conf.d/default.conf-
./nginx/dist:/usr/share/nginx/distports:-
8080:8080networks:multi-cache:ipv4_address:
172.30.3.3删除原来docker里的multiCache项目并停止springboot应用。
nginx部分配置如下监听端口为8080并且将请求反向代理至172.30.3.11下一小节将openresty固定在172.30.3.11。
-d访问http://localhost:8080/item.html?id10001查询id10001商品页
这里是假数据前端页面会向/api/item/10001发送数据请求。
在docker/docker-compose.yml中添加openresty1服务块。
openresty/openresty:1.21.4.3-3-jammy-amd64volumes:-
./openresty1/conf/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf-
./openresty1/conf/conf.d/default.conf:/etc/nginx/conf.d/default.conf-
./openresty1/lua:/usr/local/openresty/nginx/lua-
./openresty1/lualib/common.lua:/usr/local/openresty/lualib/common.luanetworks:multi-cache:ipv4_address:
前端向后端发送/api/item/10001请求关于id10001商品信息。
根据nginx的配置内容这个请求首先被nginx拦截反向代理到172.30.3.11
}openresty1收到的也是/api/item/10001同时openresty将/api/item/(\d)请求代理到指定lua程序在lua程序中完成数据缓存。
因此openresty的conf/conf.d/default.conf如下
application/json;content_by_lua_file
http://tomcat-cluster;}error_page
}conf/nginx.conf在http块最后添加3行引入依赖。
/usr/local/openresty/lualib/?.lua;;;#c模块lua_package_cpath
/usr/local/openresty/lualib/?.so;;;#本地缓存lua_shared_dict
common.lua被挂载到lualib表示可以被其他lua当做库使用内容如下
函数向openresty本身发送类似/path/item/10001请求根据conf配置将被删除/path前缀并代理至tomcat程序
ngx.location.capture(/path..path,{method
函数如果本地有缓存使用缓存如果没有代理到tomcat然后将数据存入缓存
_Mitem.lua是处理来自形如/api/item/10001请求的程序内容如下
commonUtils.read_data(item:id:..id,
commonUtils.read_data(item:stock:id:..id,
这里lua对item(tb_item表)和stock(tb_stock表)两个信息都有缓存并使用cjson库将两者合并后返回到前端。
关于expire时效性的问题如果后台改变了数据但是openresty关于此数据的缓存未过期前端得到的是旧数据。
大致来说openresty
lua不仅具有nginx反向代理的能力还能介入lua程序进行扩展。
3.8networks:multi-cache:driver:
172.30.3.0/24services:mysql:container_name:
./mysql/conf/my.cnf:/etc/mysql/conf.d/my.cnf-
MYSQL_ROOT_PASSWORD1009networks:multi-cache:ipv4_address:
172.30.3.2nginx:container_name:
./nginx/conf/nginx.conf:/etc/nginx/nginx.conf-
./nginx/conf/conf.d/default.conf:/etc/nginx/conf.d/default.conf-
./nginx/dist:/usr/share/nginx/distports:-
8080:8080networks:multi-cache:ipv4_address:
172.30.3.3openresty1:container_name:
openresty/openresty:1.21.4.3-3-jammy-amd64volumes:-
./openresty1/conf/nginx.conf:/usr/local/openresty/nginx/conf/nginx.conf-
./openresty1/conf/conf.d/default.conf:/etc/nginx/conf.d/default.conf-
./openresty1/lua:/usr/local/openresty/nginx/lua-
./openresty1/lualib/common.lua:/usr/local/openresty/lualib/common.luanetworks:multi-cache:ipv4_address:
访问http://localhost:8080/item.html?id10001
查看openresty容器日志可以看到两次commonUtils.read_data都没有缓存于是代理到tomcat可以看到springboot日志出现查询相关记录。
http://localhost:8080/item.html?id10001
http://localhost:8080/item.html?id10001
http://localhost:8080/item.html?id10001
Edg/121.0.0.0再次访问此网址强制刷新禁用浏览器缓存更换浏览器
http://localhost:8080/item.html?id10001
http://localhost:8080/item.html?id10001
Edg/121.0.0.0再次访问此网址强制刷新禁用浏览器缓存更换浏览器
http://localhost:8080/item.html?id10001
docker实例并在nginx的docker/nginx/conf/conf.d/default.conf的upstream
nginx-cluster将多个openresty地址添加进去即可。
比如
$request_uri负载均衡作为反向代理策略防止同一请求被多个实例缓存数据。
对于springboot程序高可用也是类似。
可以部署多个springboot
的docker/openresty1/conf/conf.d/default.conf的upstream
nginx-cluster将多个springboot地址添加进去即可。
比如
作为专业的SEO优化服务提供商,我们致力于通过科学、系统的搜索引擎优化策略,帮助企业在百度、Google等搜索引擎中获得更高的排名和流量。我们的服务涵盖网站结构优化、内容优化、技术SEO和链接建设等多个维度。
| 服务项目 | 基础套餐 | 标准套餐 | 高级定制 |
|---|---|---|---|
| 关键词优化数量 | 10-20个核心词 | 30-50个核心词+长尾词 | 80-150个全方位覆盖 |
| 内容优化 | 基础页面优化 | 全站内容优化+每月5篇原创 | 个性化内容策略+每月15篇原创 |
| 技术SEO | 基本技术检查 | 全面技术优化+移动适配 | 深度技术重构+性能优化 |
| 外链建设 | 每月5-10条 | 每月20-30条高质量外链 | 每月50+条多渠道外链 |
| 数据报告 | 月度基础报告 | 双周详细报告+分析 | 每周深度报告+策略调整 |
| 效果保障 | 3-6个月见效 | 2-4个月见效 | 1-3个月快速见效 |
我们的SEO优化服务遵循科学严谨的流程,确保每一步都基于数据分析和行业最佳实践:
全面检测网站技术问题、内容质量、竞争对手情况,制定个性化优化方案。
基于用户搜索意图和商业目标,制定全面的关键词矩阵和布局策略。
解决网站技术问题,优化网站结构,提升页面速度和移动端体验。
创作高质量原创内容,优化现有页面,建立内容更新机制。
获取高质量外部链接,建立品牌在线影响力,提升网站权威度。
持续监控排名、流量和转化数据,根据效果调整优化策略。
基于我们服务的客户数据统计,平均优化效果如下:
我们坚信,真正的SEO优化不仅仅是追求排名,而是通过提供优质内容、优化用户体验、建立网站权威,最终实现可持续的业务增长。我们的目标是与客户建立长期合作关系,共同成长。
Demand feedback