0

我有 HAProxy 设置,将它指向我的应用服务器的公共 IP 没有问题,但我无法让它指向私有 IP。我收到“503 Service Unavailable 没有服务器可用于处理此请求”。错误

这些是我的设置:

haproxy.cfg

global
        log 127.0.0.1   local0
        log 127.0.0.1   local1 notice
        maxconn 4096
        user haproxy
        group haproxy

defaults
        log     global
        mode    http
        option  httplog
        option  dontlognull
        retries 3
        option redispatch
        maxconn 2000
        contimeout      5000
        clitimeout      50000
        srvtimeout      50000

listen webfarm 173.255.222.100:80
       mode http
       stats enable
       stats auth deploy:d3pl0y
       balance roundrobin
       cookie JSESSIONID prefix
       option httpclose
       option forwardfor
       server App1 192.168.133.136:80 cookie App1 check

nginx.conf(用于应用服务器)

#user  nobody;
worker_processes  4;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

#pid        logs/nginx.pid;


events {
    worker_connections  1024;
}


http {
    passenger_root /opt/ruby/lib/ruby/gems/1.8/gems/passenger-3.0.2;
    passenger_ruby /opt/ruby/bin/ruby;

    include       mime.types;
    default_type  application/octet-stream;

    #log_format  main  '$remote_addr - $remote_user [$time_local] "$request" '
    #                  '$status $body_bytes_sent "$http_referer" '
    #                  '"$http_user_agent" "$http_x_forwarded_for"';

    #access_log  logs/access.log  main;

    sendfile        on;
    #tcp_nopush     on;

    #keepalive_timeout  0;
    keepalive_timeout  65;

    #gzip  on;

server {
     listen 192.168.133.136:80;
     port_in_redirect off;
     server_name localhost;
     root /var/www/current/public;
     passenger_enabled on;
     rack_env production;
     if (-f $document_root/system/maintenance.html){
             rewrite  ^(.*)$  /system/maintenance.html break;
     }


     if ($host ~* www\.(.*)) {
             set $host_without_www $1;
             rewrite ^(.*)$ http://$host_without_www$1 permanent;
     }
        }

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {
            root   html;
            index  index.html index.htm;
        }

        #error_page  404              /404.html;

        # redirect server error pages to the static page /50x.html
        #
        error_page   500 502 503 504  /50x.html;
        location = /50x.html {
            root   html;
        }

}
4

2 回答 2

1

503 表示服务器未通过检查,这只是您配置中的 TCP。我怀疑你的流量在 haproxy LB 和服务器之间被过滤了,或者服务器无法响应 LB。

于 2011-01-29T12:05:05.627 回答
0

haproxy.conf 中的后端定义在哪里?您应该定义一个默认后端并将服务器 App1 192.168.133.136:80 cookie App1 check in 放在那里并启用 Haproxy stats 以检查发生了什么。您是否还检查了防火墙并确保 192.168.133.136 响应安装了 haproxy 的服务器?

请查看以下有关使用 haproxy 进行负载平衡的文章

于 2015-10-01T20:51:30.243 回答