原文地址:http://serversforhackers.com/editions/2014/07/29/haproxy-ssl-termation-pass-through/

Overview

If your application makes use of SSL certificates, then some decisions need to be made about how to use them with a load balancer.

A simple setup of one server usually sees a client's SSL connection being decrypted by the server receiving the request. Because a load balancer sits between a client and one or more servers, where the SSL connection is decrypted becomes a concern.

There are two main strategies.

SSL Termination is the practice of terminating/decrypting an SSL connection at the load balancer, and sending unencrypted connections to the backend servers.

This means the load balancer is responsible for decrypting an SSL connection - a slow and CPU intensive process relative to accepting non-SSL requests.

This is the opposite of SSL Pass-Through, which sends SSL connections directly to the proxied servers.

With SSL-Pass-Through, the SSL connection is terminated at each proxied server, distributing the CPU load across those servers. However, you lose the ability to add or edit HTTP headers, as the connection is simply routed through the load balancer to the proxied servers.

This means your application servers will lose the ability to get the X-Forwarded-* headers, which may include the client's IP address, port and scheme used.

Which strategy you choose is up to you and your application needs. SSL Termination is the most typical I've seen, but pass-thru is likely more secure.

There is a combination of the two strategies, where SSL connections are terminated at the load balancer, adjusted as needed, and then proxied off to the backend servers as a new SSL connection. This may provide the best of both security and ability to send the client's information. The trade off is more CPU power being used all-around, and a little more complexity in configuration.

An older article of mine on the consequences and gotchas of using load balancers explains these issues (and more) as well.

HAProxy with SSL Termination

We'll cover the most typical use case first - SSL Termination. As stated, we need to have the load balancer handle the SSL connection. This means having the SSL Certificate live on the load balancer server.

We saw how to create a self-signed certificate in a previous edition of SFH. We'll re-use that information for setting up a self-signed SSL certificate for HAProxy to use.

Keep in mind that for a production SSL Certificate (not a self-signed one), you won't need to generate or sign a certificate yourself - you'll just need to create a Certificate Signing Request (csr) and pass that to whomever you purchase a certificate from.

First, we'll create a self-signed certificate for *.xip.io, which is handy for demonstration purposes, and lets use one the same certificate when our server IP addresses might change while testing locally. For example, if our local server exists at 192.168.33.10, but then our Virtual Machine IP changes to 192.168.33.11, then we don't need to re-create the self-signed certificate.

I use the xip.io service as it allows us to use a hostname rather than directly accessing the servers via an IP address, all without having to edit my computers' Host file.

As this process is outlined in a passed edition on SSL certificates, I'll simple show the steps to generate a self-signed certificate here:

$ sudo mkdir /etc/ssl/xip.io $ sudo openssl genrsa -out /etc/ssl/xip.io/xip.io.key 1024 $ sudo openssl req -new -key /etc/ssl/xip.io/xip.io.key -out /etc/ssl/xip.io/xip.io.csr > Country Name (2 letter code) [AU]:US > State or Province Name (full name) [Some-State]:Connecticut > Locality Name (eg, city) []:New Haven > Organization Name (eg, company) [Internet Widgits Pty Ltd]:SFH > Organizational Unit Name (eg, section) []: > Common Name (e.g. server FQDN or YOUR name) []:*.xip.io > Email Address []: > Please enter the following 'extra' attributes to be sent with your certificate request > A challenge password []: > An optional company name []: $ sudo openssl x509 -req -days 365 -in /etc/ssl/xip.io/xip.io.csr -signkey /etc/ssl/xip.io/xip.io.key -out /etc/ssl/xip

转载于:https://www.cnblogs.com/davidwang456/p/3880101.html

Using SSL Certificates with HAProxy--reference相关推荐

  1. linux生成ssl证书给haproxy,如何为多个SSL证书配置HAProxy

    我需要使用两个不同的SSL证书配置HAProxy > www.example.com > api.example.com 现在我从serverfault(Configure multipl ...

  2. 【SSL Certificates】什么是数字证书(Certificates)?

    本文涉及的相关问题,如果你的问题或需求有与下面所述相似之处,请阅读本文 ssl certificate 什么是ssl certificates? SSL Certificates 是一种使用数字加密技 ...

  3. 赛门铁克Symantec通配型SSL证书(Symantec Secure Site Wildcard SSL Certificates)

    赛门铁克Symantec通配型SSL证书 (Symantec Secure Site Wildcard SSL Certificates) 什么是通配符SSL证书? 我应该在什么时候申请的SSL通配符 ...

  4. 在 Postman 中报错:Self-signed SSL certificates are being blocked 的分析与解决

    http://www.shuijingwanwq.com/2019/02/18/3171/ 转载于:https://www.cnblogs.com/gzhbk/p/11387373.html

  5. haproxy详细介绍

    Haproxy是既可以工作在7层也能工作在4层的反代工具. Haproxy的功能: 路由HTTP请求到后端服务器,基于cookie作会话绑定. 能够将多个请求反代至后端主机完成负载均衡的效果. 主服务 ...

  6. haproxy实现高可用及负载均衡

    Haproxy简介:          Haproxy是一个使用c语言编写的自由开发源代码软件,它提供高可用性.负载均衡.以及基于http和tcp的应用程序代理.Haproxy特别使用于那些负载特别大 ...

  7. haproxy 反向代理 tomcat (https、负载均衡)

    背景: 情况是这样的,我们要支撑高并发业务,需要多个web服务器来支持,如果一台机器只部署一个tomcat的话,那资源没有办法充分利用,所以我们的办法是在一台物理机部署数十个tomcat,前端使用ha ...

  8. 用 HAProxy 实现网络流量的负载平衡

    在这篇文章中,我将通过设置一个非常基本的 HAProxy 环境,使用 HTTPS 来监听安全端口 443,并利用几个后端 Web 服务器.它甚至会将所有进入预定义 URL(如 /api/)的流量发送到 ...

  9. HAproxy七层负载均衡——环境搭建及实现过程详解

    实验环境 主机名 IP 服务 虚拟机server1 172.25.6.1 haproxy,httpd,服务端 虚拟机server2 172.25.6.2 httpd,php,客户端 虚拟机server ...

最新文章

  1. 可由一个尾指针唯一确定的链表有_极客算法训练笔记(三),链表详细图解,别再逃避了朋友...
  2. JavaScript中对象成员的可见性
  3. 【算法习作】荷兰国旗问题
  4. 使用 C# 编程对RTF文档的支持
  5. 自适应图片大小的弹出窗口(3 中方法)
  6. 20个软件开发常用设计文档大全下载
  7. 这种思路讲解数据仓库建模,你见过吗?数据人与架构师必看
  8. 每天一道算法题(16)——翻转链表
  9. Unity DOTS在hybird renderer v2 中rendermesh不显示
  10. 继谷歌之后 雅虎退出中国音乐市场
  11. Edge地址栏搜索引擎换成Bing
  12. 电视剧《大秦赋》最近很火!于是我用Python抓取了“相关数据”,发现了这些秘密.........
  13. Axure8有效注册码
  14. 2021年全国计算机南京考点,2021考研考场安排:往年南京市考研考点及考场安排
  15. android libbinder – Binder的Native实现
  16. Fourier分析入门——第1章——数学预备知识
  17. 我和王争学设计模式|抽象工厂
  18. 软件的版权和专利辨析
  19. EFR32 资源汇总
  20. ZYNQ学习笔记(五)---按键控制LED灯亮灭实验

热门文章

  1. 用计算机怎么开5次方,用科学计算器来求三的五次方的值,按键顺序是( )?
  2. php调用其它控制器,TP框架控制器里面怎么调用另一个控制器的代码
  3. cstart做int型转换运算Java,Java实验练习题目-供练习参考
  4. lstm结构图_神经网络——单层LSTM
  5. yii 清除mysql缓存_Yii2开启数据表结构缓存和清除
  6. 使用ifstream从文件中读取内容
  7. 字符集:ASCII、GB2312、GBK、GB18030、Unicode
  8. mysql join大小表顺讯_MySQL优化器join顺序
  9. AlertDialog(对话框)的基本使用
  10. sql PERCENTILE_CONT 计算一组数的线性差值