Haproxy 503服务不可用。没有服务器可用于处理此请求

 你一句话就逼我撤退 发布于 2023-02-07 09:22

haproxy如何处理静态文件(如.css,.js,.jpeg)?当我使用配置文件时,浏览器会说:

503服务不可用

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

这是我的配置:

global
  daemon
  group root
  maxconn  4000
  pidfile  /var/run/haproxy.pid
  user root

defaults
  log  global
  option  redispatch
  maxconn 65535
  contimeout 5000
  clitimeout 50000
  srvtimeout 50000
  retries  3
  log 127.0.0.1 local3
  timeout  http-request 10s
  timeout  queue 1m
  timeout  connect 10s
  timeout  client 1m
  timeout  server 1m
  timeout  check 10s


listen dashboard_cluster :8888
  mode http
  stats refresh 5s
  balance roundrobin
  option httpclose
  option tcplog
  #stats realm Haproxy \ statistic
  acl url_static path_beg -i /static
  acl url_static path_end -i .css .jpg .jpeg .gif .png .js
  use_backend static_server if url_static

backend static_server
  mode http
  balance roundrobin
  option httpclose
  option tcplog
  stats realm Haproxy \ statistic
  server controller1 10.0.3.139:80 cookie controller1 check inter 2000 rise 2 fall 5
  server controller2 10.0.3.113:80 cookie controller2 check inter 2000 rise 2 fall 5

我的档案有误吗?我该怎么做才能解决这个问题?!

1 个回答
  • 我认为是原因:

    没有default_backend定义。HAProxy将发送503,这将显示NOSRV在日志中。

    另一个可能的原因

    根据我的经验之一,我收到的HTTP 503错误是由于我具有相同IP和端口的2个绑定所致x.x.x.x:80

    frontend test_fe
         bind x.x.x.x:80
         bind x.x.x.x:443 ssl blah
    
         # more config here
    
    frontend conflicting_fe
         bind x.x.x.x:80
    
         # more config here
    

    Haproxy配置检查不会警告您,netstat也不会显示2 LISTEN个条目,这就是为什么花了一些时间才意识到正在发生的事情的原因。

    如果您有2个haproxy服务正在运行,也会发生这种情况。请检查正在运行的进程并终止较旧的进程。

    2023-02-07 09:25 回答
撰写答案
今天,你开发时遇到什么问题呢?
立即提问
热门标签
PHP1.CN | 中国最专业的PHP中文社区 | PNG素材下载 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有