当前位置:网站首页>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; }
边栏推荐
- At least 3 years for learning amplifier?
- 解释PBR纹理贴图(texture-maps)
- Exercise 8 Chapter 8 Verilog finite state machine design -4 Verilog quartus Modelsim
- Tag based augmented reality using OpenCV
- 使用Gunicorn部署web.py应用
- [notes] take notes again -- learn by doing Verilog HDL – 014
- Cantata version 9.5 has officially passed the sgs-t Ü V certification and conforms to all major software safety standards
- Stm32cubemx learning (6) external interrupt experiment
- How to evaluate iFLYTEK AI translation pen P20 series? Is it worth buying?
- Hangfire详解
猜你喜欢

Logical structure and physical structure

Cmake开发-多目录工程

期末复习【微机原理】

广东二级造价工程师《造价管理》真题解析

MySQL JSON data types & functions

In depth good article | yolov5+deepsort multi-target tracking in-depth interpretation and testing (including source code)

「运维有小邓」Active Directory 密码过期通知功能
【云原生实战】KubeSphere实战——多租户系统实战

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

CAD assistant - 3D model format conversion tool
随机推荐
解释PBR纹理贴图(texture-maps)
Three. JS development: drawing of thick lines
Is it safe to open a new bond Online
「运维有小邓」Active Directory 密码过期通知功能
How to use filters in jfinal to monitor Druid for SQL execution?
Analysis of the underlying architecture of spark storage system - spark business environment practice
Alibaba cloud released the atlas of China's robot industry (2022), 122 Pages pdf
【编译原理】语法分析
jfinal中如何使用过滤器监控Druid监听SQL执行?
18. `bs对象.节点名.next_sibling` previous_sibling 获取兄弟节点
thinkphp5中的配置如何使用
输入年份与月份,求该月共有多少天
High energy live broadcast, a gathering of celebrities! We invite you to explore bizdevops.
The foundation and application of quantum machine learning: a concise literature review
「运维有小邓」日志分析工具使用越来越频繁的原因
利用积分商城游戏进行营销需要避免哪些问题出现?
「运维有小邓」AD域委派
「运维有小邓」审核并分析文件和文件夹访问权限
Curl download example
日本樱桃一颗拍出1980元天价,网友:吃了有上当的感觉