出于性能原因,我在 nginx 前面使用了 HAProxy,而且我似乎无法使用 unix socket 进行 HAProxy 和 Nginx 之间的通信。
HAProxy 配置:
backend nginx
option forwardfor
option http-server-close
server nginx_unix /var/run/nginx-webhook.sock check send-proxy
Run Code Online (Sandbox Code Playgroud)
Nginx 配置:
server {
listen 8080 proxy_protocol;
listen unix:/var/run/nginx-webhook.sock proxy_protocol;
...
}
Run Code Online (Sandbox Code Playgroud)
套接字确实存在:
$ ls -lah /var/run/nginx-webhook.sock
srw-rw-rw- 1 root root 0 Feb 7 19:29 /var/run/nginx-webhook.sock
Run Code Online (Sandbox Code Playgroud)
这是我从 HAProxy 状态页面得到的错误:
Mar 17 14:38:42 app01 haproxy[11597]: Server nginx/nginx_unix is DOWN, reason: Socket error, info: "General socket?
error (No such file or directory)", check duration: 0ms. 1 active and 0 backup servers left. 0 sessions active, 0?
requeued, 0 remaining in queue.
Run Code Online (Sandbox Code Playgroud)
不知道出了什么问题;毕竟插座确实存在。
小智 7
我在使用Varnish 6.0.3作为后端的Debian Buster上的Haproxy 1.8.19遇到了同样的问题。
对我来说,问题来自Haproxy 配置中的chroot选项:
chroot /var/lib/haproxy
Run Code Online (Sandbox Code Playgroud)
您有两种解决方案可以解决此问题:
将您的 Nginx Unix 套接字移动到 chroot 目录中
或者禁用 chroot 选项,但出于安全原因不建议这样做。
| 归档时间: |
|
| 查看次数: |
679 次 |
| 最近记录: |