https 不支持 haproxy

标签 https haproxy

我必须将 haproxy 放在我已经运行的 Apache 网络服务器前面。 haproxy 和 apache web-server 都在不同的 Cent-OS6.4 机器上。 我已经安装了 haproxy-1.5-dev19.el6.x86_64 并且它在 http 上工作正常,但是越来越 以下错误与 https:- “502 错误网关:服务器返回无效或不完整的响应”。

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"

网络服务器上的 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 日志(直接请求):

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。

我哪里做错了?请帮助我解决这个问题。

问候,

科马尔帕尔

最佳答案

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

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

如果你想重新加密,你必须改变你的“server xxx”行以在它上面也有标志“ssl”。

关于https 不支持 haproxy,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19830271/

相关文章:

mysql主从复制与haproxy

ssl - Certbot 检测到不正确的通用名称 (CN)

php include 在切换到 SSL 时不起作用

linux - 无法使用 HAProxy 将客户端 IP 转发到服务器

mysql -/usr/bin/docker-当前 : Error parsing reference . 。引用格式无效

ssl-certificate - 为什么HAProxy无法加载letsencrypt生成的证书?

nginx 位于 haproxy 后面 varnish 后面

ios - iOS 应用程序提交中的导出合规性

python - python 中本地 https 服务器上的 SSL 异常

node.js - HTTPS 重定向仅在页面重新加载时有效