小编Sim*_*ted的帖子

当 Nginx 在 HAProxy 后面使用 unix 套接字时出现“一般套接字错误”

出于性能原因,我在 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 状态页面得到的错误:

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 …
Run Code Online (Sandbox Code Playgroud)

nginx

4
推荐指数
1
解决办法
679
查看次数

标签 统计

nginx ×1