当前位置:网站首页>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; }
边栏推荐
- Detailed description of gaussdb (DWS) complex and diverse resource load management methods
- Withdrawal of user curve in qualified currency means loss
- Go: how to write a correct UDP server
- C#_ Convert camera images to bitmap format and draw Crosshairs
- SSH命令及使用说明
- A Japanese Cherry sold at a sky high price of 1980 yuan. Netizen: I feel cheated after eating it
- Curl download example
- Cantata version 9.5 has officially passed the sgs-t Ü V certification and conforms to all major software safety standards
- 导航【微机原理】
- .NetCore统一认证授权学习——Run(1)
猜你喜欢
![[compilation principle] syntax analysis](/img/9e/6b1f15e3da9997b08d11c6f091ed0e.png)
[compilation principle] syntax analysis

Bigder:自动化测试工程师

Chainsafe cross chain bridge deployment tutorial

Coreldraw2022 new version v24.1.0.360 update

VoIP Push 在海外音视频业务中的应用

. NETCORE unified authentication authorization learning - first authorization (2)
![[compilation principle] type check](/img/fc/458871e2df4e0384f65e09faa909d7.png)
[compilation principle] type check

18. `bs object Node name next_ sibling` previous_ Sibling get sibling node

Information system project manager -- Chapter VII examination questions of project cost management over the years

「运维有小邓」实时监控用户登录操作
随机推荐
Coreldraw2022 new version v24.1.0.360 update
Community interview -- jumpserver open source fortress in the eyes of an it newcomer
The foundation and application of quantum machine learning: a concise literature review
注解
Enter the year and month to find the total number of days in the month
Bigder:自动化测试工程师
Ovirt database modify delete node
How to use filters in jfinal to monitor Druid for SQL execution?
Final review [microcomputer principle]
「运维有小邓」日志分析工具使用越来越频繁的原因
Flume ng configuration
Hangfire详解
智能门锁主流品牌有哪些?选购门锁时要注重产品的哪些特性?
tmux设置
[buuctf.reverse] 142_ [SUCTF2019]babyunic
The explain statement in MySQL queries whether SQL is indexed, and several types in extra collate and summarize
网站压力测试工具——Webbench
Lexin interview process
Defense cornerstone in attack and defense drill -- all-round monitoring
如何审核 Active Directory 用户账户更改?