为什么 HAProxy 无法连接到我的本地服务器,而我的浏览器可以?

问题描述 投票:0回答:1

我使用的是 Mac 操作系统。当我在网络浏览器中访问

http://localhost:8085
时,我看到我的 Nginx 服务器正常工作,但我的后端配置如下:

frontend api_gateway
    bind :8080
    mode http
    default_backend nginx

backend nginx
    mode http
    server nginx localhost:8085

当转到

http://localhost:8080
时,我收到错误:

503 服务不可用

没有服务器可以处理此请求。

macos nginx haproxy
1个回答
0
投票

在我的例子中,这是由于 Nginx 侦听

127.0.0.1
(IPv4 地址),但 HAProxy 正在连接
::1
IPv6 地址。

为了解决这个问题,我改变了线路

server nginx localhost:8085

server nginx 127.0.0.1:8085

尽管另一种选择是将 Nginx 配置为侦听 IPv6。

© www.soinside.com 2019 - 2024. All rights reserved.