ubuntu - Haproxy 1.4 连接到 https 后端服务器

标签 ubuntu ssl https openssl haproxy

我正在尝试使用端口 443 通过 https 连接到 2 个后端服务器,并且我想找到一种将 key 和证书文件发送到后端服务器的方法。我的 haproxy.cfg 是:

global
    log 127.0.0.1   local0
    log 127.0.0.1   local1 notice
    #log loghost    local0 info
    maxconn 4096
    #chroot /usr/share/haproxy
    user haproxy
    group haproxy
    daemon
    #debug
    #quiet

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

listen stats :8000
    #mode http
    stats enable
    stats realm Haproxy\ Statistics
    stats uri /
    stats auth admin:password


listen  ssl-relay :80
    mode tcp
    balance roundrobin
    stick-table type ip size 200m expire 30m
    stick on src
    server  server01 www.example.com:443 check inter 2000 fall 3
    server  server02 www.example.com:443 check inter 2000 fall 3

怎样才能让haproxy服务器和后端服务器之间的通信安全???

最佳答案

您的客户会使用 https://myfakepage.com:80作为网址?如果不是,那么你所做的事情基本上毫无意义。您正在处理与前端的未加密连接,然后是与后端的加密连接。问题是,当连接返回到客户端时,它将是未加密的,因此您不会为自己购买任何东西。如果您的客户将使用https://pmyfakepage.com:80那么就没有什么可做的,因为 haproxy 已经充当 https 流量的传递。

您是否尝试在负载均衡器上执行 SSL 终止,如果是,则您正在执行反向操作

你的绑定(bind)部分看起来像这样

frontend ssl-site
bind *:443 ssl crt /path/to/bundle.pem  #you need to make sure the whole cert path is in one pem file
reqadd X-Forwarded-Proto:\ https
default_backend myServers

backend myServers
balance roundrobin
server server1 www.example.com:80
server server2 www2.example.com:80

但正如 dtorgo 所说,这种方式的 ssl 终止仅适用于 1.5 及更高版本。如果您发现 stunnel 太慢,另一个选择是螺柱。

希望这能为您解决问题。

关于ubuntu - Haproxy 1.4 连接到 https 后端服务器,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18516959/

相关文章:

php - 带数据的 Alamofire POST 请求

c - `configure.ac` 文件给出错误

php - ubuntu php 忽略 ini_set ("disply_error")并仅使用 php.ini 设置

ubuntu - gpg : WARNING: unsafe ownership on configuration file, $gpg --Ubuntu9.10 上的指纹

c++ - 无法使用icpc打开源文件 "bits/c++config.h"错误

SOAP 1.2 通过 SSL + HTTP 基本身份验证还是 WS-Security?

android - 无法在工作资料上的 Android 11 上安装 CA 证书

ssl - 跳过 IIB 中的证书验证

ssl - 解析 SSL 证书问题

http - HTTPS 中的哪些 HTTP 功能不同?