https不是在haproxy背后工作

时间:2013-11-07 07:33:14

标签: https haproxy

我必须将haproxy放在我已运行的Apache Web服务器前面。 haproxy和apache web-server都在不同的Cent-OS6.4机器上。 我已经安装了haproxy-1.5-dev19.el6.x86_64,它可以正常使用http,但是得到了 以下错误与https: -     “502 Bad Gateway:服务器返回了无效或不完整的响应”。

haproxy日志如下所示:

Nov  7 05:49:56 localhost haproxy[9925]: XX.XX.XXX.XX:51949
[07/Nov/2013:05:49:55.204] https-in~ abc-https/server1
1595/0/1/-1/1597 502 714 - - PHNN 2/2/0/0/0 0/0 "GET / HTTP/1.1"

Nov  7 05:49:57 localhost haproxy[9925]: XX.XX.XXX.XX:51947
[07/Nov/2013:05:49:55.972] https-in~ abc-https/server1
1523/0/1/-1/1525 502 714 - - PHNN 1/1/0/0/0 0/0 "GET /favicon.ico HTTP/1.1"

Web服务器上的SSL日志(代理后面的请求):

10.0.0.218 - - [06/Nov/2013:22:42:34 -0800] **"GET /"** 400 510
10.0.0.218 - - [06/Nov/2013:22:42:34 -0800] "GET /" 400 510

SSL登录webserver(直接请求):

XX.XX.XX.XX - - [06/Nov/2013:22:48:42 -0800] **"GET / HTTP/1.1"** 200 19553

正如您可以在网络服务器上看到代理与无代理之间的区别。

以下是我的haproxy.cfg文件:

global
    log         127.0.0.1 local2
    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     40000
    user        haproxy
    group       haproxy
    daemon

    stats socket /var/lib/haproxy/stats

defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor   
    option                  redispatch
    retries                 10
    timeout http-request    60s
    timeout queue           60s
    timeout connect         60s
    timeout client          60s
    timeout server          60s
    timeout http-keep-alive 60s
    timeout check           60s
    maxconn                 30000

Listen stats 0.0.0.:8880
    stats enable
    stats hide-version
    stats uri   /
    Stats realm HAProxy\ Statistics
    stats auth XXXXX:XXXXX

frontend http-in
    bind *:80
    acl url_static       path_beg       -i /static /images /javascript /stylesheets
    acl url_static       path_end       -i .jpg .gif .png .css .js
    tcp-request connection accept if { src -f /etc/haproxy/whitelist.lst } 
    tcp-request connection reject if { src_conn_cur ge 200 }   tcp-request
    connection track-sc1 src

    use_backend http-in-static if url_static
    default_backend           http-in-bk

frontend https-in
    bind *:443 ssl crt /home/ec2-user/ev/haproxy.pem
    http-request add-header X-Proto https if { ssl_fc }
    use_backend abc-https if {ssl_fc}

backend abc-https
    server server1 10.0.0.16:443 check 

backend http-in-static
     server static 10.0.0.16:80 check inter 100 weight 1

backend http-in-bk
    acl abuse src_http_err_rate(http-in) ge 100
    acl flag_abuser src_inc_gpc0(http-in)
    tcp-request content reject if abuse flag_abuser
    server  server1 10.0.0.16:80 check  inter 100 weight 1

只有一个网络服务器已在运行,我必须在其前面实现haproxy。

我做错了什么?请帮我解决这个问题。

此致

Komal Pal

1 个答案:

答案 0 :(得分:5)

您正在解密SSL流量,然后将明文HTTP发送到您的网络服务器上的HTTPS套接字。

在此设置中,您通常会将其发送到网络服务器上的端口80,因为您已经解密了它。

如果要重新加密,则必须更改“server xxx”行,以便在其上添加标记“ssl”。