当前位置:网站首页>varnish 503 no backend connection – varnish健康检查
varnish 503 no backend connection – varnish健康检查
2022-06-29 20:49:00 【星哥玩云】
varnish开启之后过一段时间就出现503错误,直接访问后端OK,前端ping后端OK,原因是varnish判断后端已挂掉,拒绝请求。 在配置backend时,配置了.prob,配置如下:
.probe= { .url = "/"; .timeout = 1s; .interval = 10m; .window = 10; .threshold = 8; .expected_response = 200; } 后端:nginx,php,yii框架,url重写 请求被转发到后端的 "/"上,经过yii路由,最后的请求地址为/site/index,也就是请求SiteController中的actionIndex,在做项目的时候还没有加入SiteController,所以后端给前端404,与.expected_response = 200不一致,当varnish重试几次以后就会判断后端为挂了。 所以建议在后端加一个varnish专用的检测文件,如 .probe= { .url = "/varnishTest"; .timeout = 1s; .interval = 10m; .window = 10; .threshold = 8; .expected_response = 200; } 当varnish检测的时候就会去请求 /varnishTest,经过yii路由,得到请求地址/varnishTest/index,此时会返回200,问题就解决了。 为了防止用户直接访问到varnish专用的测试地址,可以在varnish请求中加入set req.http.FromVarnish = "yes";,也就是在header中加入一个变量,在PHP中检测 <?php if ( isset($_SERVER['FromVarnish']) && $_SERVER['FromVarnish'] === 'yes' ){ echo 'yes'; }else { header("HTTP/1.1 404 Not Found");exit; }
边栏推荐
- AI scene Storage Optimization: yunzhisheng supercomputing platform storage practice based on juicefs
- Navigation exercises [microcomputer principles] [exercises]
- The reason why the log analysis tool of "operation and maintenance" is used more and more frequently
- Exit operation in project
- Following the crowd hurts you
- 【云原生实战】KubeSphere实战——多租户系统实战
- Nutch2.1 distributed fetching
- 日本樱桃一颗拍出1980元天价,网友:吃了有上当的感觉
- Exercise 8 Chapter 8 Verilog finite state machine design -4 Verilog quartus Modelsim
- Curl download example
猜你喜欢

【编译原理】语法分析

STL教程6-deque、stack、queue、list容器

Three.js开发:粗线的画法
![[compilation principle] type check](/img/fc/458871e2df4e0384f65e09faa909d7.png)
[compilation principle] type check

Withdrawal of user curve in qualified currency means loss

分析影响导电滑环传输信号的因素

「运维有小邓」Active Directory 密码过期通知功能

Hangfire details

"Xiaodeng" active directory password expiration notification function is available for operation and maintenance

计算成像前沿进展
随机推荐
Application of twelve factors (4)
Hangfire详解
[notes] take notes again -- learn by doing Verilog HDL – 008
时钟树综合(CTS)
Analysis of the underlying architecture of spark storage system - spark business environment practice
18. `bs对象.节点名.next_sibling` previous_sibling 获取兄弟节点
「运维有小邓」审核并分析文件和文件夹访问权限
[today in history] June 29: SGI and MIPS merged; Microsoft acquires PowerPoint developer; News corporation sells MySpace
导航 习题【微机原理】【习题】
Command execution (RCE) vulnerability
【编译原理】语法分析
Tag based augmented reality using OpenCV
Navigation exercises [microcomputer principles] [exercises]
【编译原理】类型检查
[compilation principle] semantic analysis
Coreldraw2022 new version v24.1.0.360 update
18. `bs object Node name next_ sibling` previous_ Sibling get sibling node
Win10 sets automatic dial-up networking task to realize automatic reconnection after startup and disconnection
mapbox-gl开发教程(十二):加载面图层数据
0/1分数规划专题