Tech Recipe Book
My Services
  • Book
    • About the author
    • Architect
      • Algorithms
        • DB index algorithms
          • How does database indexing work
        • Neural network optimization
          • Neural Network Optimization
        • Route search
          • Road network in a database to build a route
          • Traveling Salesman Problem (TSP)
      • Architecture Frameworks
        • DODAF
        • TOGAF
        • Enterprise Architecture (EA) Tools Reviews 2023 | Gartner
      • Zero Trust
      • Billing
        • SHM billing system
      • Bots
        • Discord
        • Telegram
          • Chat GPT Telegram bot
          • Получаем статистику Telegram-канала при помощи api и python или свой tgstat с регистрацией и смс
          • Как хостить телеграм-бота (и другие скрипты на Python) на Repl.it бесплатно 24/7
          • Создание Telegram бота на PHP #1: основные понятия для работы с API
          • Создание Telegram бота на PHP #2: создание первого бота для Telegram
          • Создание Telegram бота на PHP #3: примеры отправки сообщений с кнопками в Telegram
          • Создание Telegram бота на PHP #4: отправка файлов и изображений в Telegram
          • Создание Telegram бота на PHP #5: работа с хуками
      • Business intelligence
      • Cloud Storage
        • Ceph
        • Virtual Distributed File System
      • Cryptography
        • Open Source PKI Software
        • OpenPGP
          • Email Encryption
          • Kleopatra
          • Miscellaneous Tools
          • Server side applications
      • Message broker
        • Kafka
          • Kafka UI-tools
          • Kafka streams ksqlDb
        • RabbitMQ
      • DB
        • MySQL
          • Auto sharding
          • MariaDB Zabbix monitoring
          • MySQL and MariaDB replication with Zabbix monitoring
        • Postgres
          • HA PostgreSQL with Patroni, Haproxy, Keepalived
          • Mass parallel requests - Greenplum
          • PostgreSQL cluster for development and testing
        • Vitess - Scalable. Reliable. MySQL-compatible. Cloud-native. Database.
      • Identity and Access Management (IDM)
        • FreeIPA - Identity, Policy, Audit
        • FreeIPA as an Enterprise solution
        • Keycloak
          • Keycloak HA cluster
        • Open Identity Platform
        • SSO
          • Keycloak for Java app
          • OpenAM
          • OpenIG
      • Firewall
        • nftables
      • Infrastructure As a Code
        • Ansible
        • IaC Packer Ansible Teraform
        • Installing Jenkins using terraform in Kubernetes in Yandex Cloud with letsencypt
        • Teraform Crosplan Pulumi
        • Yandex IaC solutions
      • Kubernetes
        • Installation
          • Install Kubernetes cluster
          • Deploying a Kubespray cluster to OpenStack using Terraform
          • Kube deploy in Yandex cloud
        • Frameworks
          • Deckhouse
            • LDAP authentification
            • On premise Install
            • Yandex Cloud Install
          • K3S
          • OpenShift OKD
          • RKE2
          • Rancher
            • Rancher Install
        • Auth
          • Keycloak in k8s
          • LDAP
        • GUI management Lens
        • Monitoring
          • Monitoring with Falco
          • Network monitoring
          • Nginx ingress
          • Prometheus Graphana for sample Nodejs app
          • Rsource monitoring Avito
        • Exposing services
          • Exposing Kubernetes Services
          • Cilium BGP
        • CNCF
        • Helm
          • Repositories
            • Artifact Hub | official
            • Bitnami | vmware
          • Awesome helm charts and resources
          • Essential Services for Modern Organizations
          • Security and Compliance
          • Additional charts
        • Isolation
          • vcluster - Virtual Kubernetes Clusters
          • Kiosk
          • KubeArmor
          • Control Plane Hardening
          • Hierarchical namespaces
        • Security Center
          • Minesweeper
          • NeuVector by SUSE
          • SOAR in Kubernetes
          • Security Сenter for Kubernetes
        • Terraform CI security
          • Terraform plan analysis with Checkov and Bridgecrew
          • Yandex Terraform scan
        • Vulnerability management
          • Aqua
          • Sysdig
          • Kyverno
          • GitLab
          • NeuVector by SUSE
        • Image scanning
          • Snyk
          • Sysdig
          • Harbor
          • Trivy
        • Signature verification
          • Sigstore
        • Control plane security
          • Gatekeeper
            • Applying OPA Gatekeeper
          • Kyverno
            • Policy as a code. Kyverno
        • Runtime Security
          • Osquery
          • Falco
          • ClamAV
        • Network security
          • Cilium
          • Control Plane Hardening (API restriction)
          • Network policy recipes
          • Service mesh
            • Istio HA, LoadBalance, Rate limit
          • mTLS Autocert
        • Honeypot
          • Building honeypot using vcluster and Falco
        • Backup
          • Kasten K10
        • Secrets
          • Vault CSI Driver
      • Load Balance
        • Nginx
        • HAProxy
          • Proxy methods
          • HAProxy for RDP
          • Payment gateway A/B test with HAProxy
          • HAPRoxy for Percona or Galera
      • Monitoring
        • Zabbix
          • Apache Zabbix
          • Disc Quota
          • Nginx Zabbix
          • SSL certificates Zabix
          • Zabbix notifications
        • Nagios
          • Datacenter monitoring
        • Prometheus and Grafana
      • Windows
        • Sysmon enhanced Windows audit
        • Sysmon to Block Unwanted File
      • Linux
        • Rsync
        • Debian based
          • Apt-Cacher NG
          • Unattended Upgrades in Debian / Ubuntu
        • RedHat basede
          • RPM Server
        • Logs analysis
        • Build armhf qemu
      • NGFW
      • CI/CD
        • DevSecOps
          • DAST
            • Burp
              • Dastardly
            • StackHawk
            • ZAP and GitHub Actions
          • SAST
            • Checkmarx
            • OSV by Google
            • Snyk
            • SonarQube
        • GitLab Runner in Yandex Cloud
        • Dynamic Gitlab Runners in Yandex Cloud
        • GitLab runner in Kubernetes with Werf
        • Kubernetes deploy strategies
        • Kubernetes highload deploy. part 1
        • Kubernetes highload deploy. part 2
        • Kubernetes Argo Rollouts
        • Jenkins in Kubernetes
        • Ansible Semaphore
        • Image storage, scaning and signing
        • Install WireGuard with Gitlab and Terraform
        • CI/CD example fror small web app
        • Threat matrix for CI CD Pipeline
      • SIEM / SOC
        • Datadog
        • Splunk
          • Splunk — general description
        • MaxPatrol
          • MaxPatrol 8 and RedCheck Enterprise
        • QRadar IBM
        • Cloud Native Security Platform (CNAPP) - Aqua
        • OSSIM | AT&T
          • AlienVault (OSSIM) install
        • Wazuh
        • EDR
          • Cortex XDR | Palo Alto Networks
          • Cynet
          • FortiEDR | Fortinet
          • Elastic
        • Elastic
          • Install Elasticsearch, Logstash, and Kibana (Elastic Stack) on Ubuntu 22.04
          • Setting Up Elastic 8 with Kibana, Fleet, Endpoint Security, and Windows Log Collection
        • Threat Intelligence
          • MISP
          • msticpy Microsoft
          • X-Force | IBM
          • Elastic
      • VPN
        • Full-Mesh VPN fastd, tinc, VpnCloud
        • Wireguard
          • WireGuard for Internet access
          • WireGuard on MikroTik and Keenetic
          • WireGuard site to site
        • SoftEther VPN Project
        • Cisco AnyConnect client
        • OpenConnect
        • SSTP python server
      • OS hardening
        • CIS Benchmarks
      • Cloud Providers
      • OpenNebula
        • OpenNebula Edge Cloud - Open Source Cloud & Edge Computing
        • Discover OpenNebula – Open Source Cloud & Edge Computing Platform
        • OpenNebula Multi-Cloud
        • Kubernetes on OpenNebula
        • The Open Source Alternative to Nutanix
        • The Simple Alternative to OpenStack
        • OpenNebula Partner Ecosystem
      • OpenStack
        • Install manual
        • Install with DevStack
      • VM
        • Create a VHD file from a Linux disk
        • Backup / Migration
          • Coriolis
          • Proxmox Backup Server
        • oVirt
        • VMware vCenter
        • Proxmox
      • Docker
        • Container optimization
        • Ubuntu RDP container
      • LXC
        • LXD on Ubuntu 18.04
        • Install, Create and Manage LXC in Ubuntu/Debian
    • Big Data
      • OLAP data qubes
      • Storage and autoscale in Lerua
    • Machine Learning
      • Yandex YaLM 100B. GPT model
      • Kaggle Community Datasts Models
      • AI in video production
      • Image search
      • Chat bots
        • You.com
        • Chat GPT
          • Implementing GPT in NumPy
        • Jailbreak Chat
      • Coding plugins CodeWhisperer
    • Malware
      • Isiaon/Pitraix: Modern Cross-Platform Peer-to-Peer Botnet over TOR
      • theZoo A repository of LIVE malwares
    • Pentest
      • Red Team
        • MITRE ATT&CK matrix
        • C2 Frameworks
          • Brute Ratel C4
          • Cobalt Strike
          • Covenant
          • Havoc Framework
          • Merlin
          • Metasploit
          • Sillenttrinity
          • Sliver
        • Manage and report
          • Dradis Framework
          • Hexway
        • Underground
      • Social engineering
        • Social Engineer Toolkit setoolkit
      • OSINT
        • OSINT for comapny
        • Instagram fishing
      • Forensics
        • Forensics tools
      • Pentesting Methodology
      • Web
      • CI/CD Methodology
      • Cloud Methodology
        • Hacking The Cloud
      • Kubernetes Pentesting
      • Android
        • SSL Unpinning for Android applications
      • iOS
        • SSL unpinning iOS and macOS applications
      • HackBar tool
      • CyberChef Tools
      • Python virtualenv
      • IppSec - YouTube
      • Hacktricks.xyz
    • Compliance
      • 152 ФЗ. Personal data
      • PCI DSS and ГОСТ Р 57580.1-2017
      • Cloud compliance
      • ГОСТ Р 57580.1-2017 для Kubernetes
      • Kubernets as DevSecOps and NIST compliance
      • NIST SP 800-61 cyberincidece control
      • CIS Kubernetes Benchmark v1.6 - RKE2 v1.20
      • CIS Kubernetes Benchmark v1.23 - RKE2
      • Requirements for Russian Banks
      • Tools
        • Chef InSpec
        • Elastic SIEM
    • Asset management
      • CMDBuild
    • Project management
    • Incident management SRE
    • Risk management
      • IT risk management
      • BSI-Standard 200-3
    • Web Dev
      • Cookie security
      • OWASP Top 10 2021
      • Docker nginx php mysql
      • Docker tor hiddenservice nginx
      • Docker Compose wp nginx php mariadb
      • Dependency Checking
        • Nexus Analyzer
        • OWASP dependency-check
      • Yii skeeks cms
      • YiiStudio
    • Art
      • GTK Themes
      • Themes for Xfce Desktop
      • XFCE / Xubuntu Windows 95
      • Moscow events
      • Photo goods
      • Russian style gifts
    • Cryptocurrency
      • News
      • Arbitrage
      • Stocks
      • Exchange aggregators
      • Where to use
      • Prepaid cards
        • BitFree
        • Pyypl Your Money at Your Fingertips
    • IT magazines
      • WIKI and Writeups tools
        • BookStack
        • GitBook
        • MkDocs
        • Wiki.js
        • DokuWiki
    • Languages
    • Learning
      • (ISC)2
        • CISSP
      • Offensive Security
        • OSCP
        • OSEP
        • OSED
      • DevSecOps
        • Certified DevSecOps Professional (CDP)
        • Certified DevSecOps Expert (CDE)
      • Web Security Academy: PortSwigger
    • Relocation
      • London experience
      • IT visas in 2022
      • Remote work
      • Running business in UAE
    • Freenet
      • Independent online services: the philosophy of a free Internet
      • Tor Project Anonymity Online
      • I2P Anonymous Network
    • Services
      • SMS Registration
        • Registering ChatGPT in Russia
      • Local and regional eSIMs for travellers - Airalo
      • Digital busines cards
      • No KYC services and exchanges
Powered by GitBook
On this page

Was this helpful?

  1. Book
  2. Architect
  3. Load Balance
  4. HAProxy

Proxy methods

Last updated 1 year ago

Was this helpful?

Недавно пришлось разбираться с проксированием доступа к веб-серверам с помощью HAProxy. Основная проблема оказалась в шифрованном доступе. Кому интересна эта тема, добро пожаловать под кат.

Есть в нашей компании ряд веб-серверов. Для экономии адресов доступ к ним организован через HAProxy. Примерно вот так:

При этом конфигурация самого HAProxy крайне простая (пример №1):

*frontend http_frontend bind :80 mode http option httpclose acl is_mytest1 hdr_end(host) -i mytest1.loc use_backend mytest1_web if is_mytest1 acl is_mytest2 hdr_end(host) -i mytest2.loc use_backend mytest2_web if is_mytest2 backend mytest1_web mode http cookie SERVERID insert indirect nocache server mytestweb1 192.168.1.5:80 check cookie mytestweb1 backend mytest2_web mode http cookie SERVERID insert indirect nocache server mytestweb2 192.168.1.10:80 check cookie mytestweb2

Здесь и далее я буду приводить не полные примеры конфиг-файла, а только интересующие нас куски.

Предельно просто — слушаем 80 порт и разбираем весь входящий траффик. Если запрашивается mytest1.loc, то он попадает в access-list is_mytest1, в этом случае используется бэкенд mytest1_web, в котором мы перенаправляем траффик на внутренний хост 192.168.1.5, где у нас и находится данный сайт. Аналогично и для mytest2.loc. Все предельно просто и при этом мы экономим реальные IP адреса.

Встал вопрос отказоустойчивости, тем более что в соседнем городе у нас тоже есть сервера, где мы можем поднять данные веб-сайты. Ну и есть виртуалка с линуксом в облаке Amazon, которая делает тоже самое, но для сайтов, расположенных в облаке. Можем ли мы использовать 2 HAProxy подряд? Поднимаем примерно такую тестовую схему и смотрим:

Конфигурации HAProxy2 и HAProxy3 не изменились, однако в HAProxy1 добавился параметр балансировки (пример №2):

*frontend http_frontend bind :80 mode http option httpclose acl is_mytest1 hdr_end(host) -i mytest1.loc use_backend mytest1_web if is_mytest1 acl is_mytest2 hdr_end(host) -i mytest2.loc use_backend mytest2_web if is_mytest2 backend mytest1_web mode http balance roundrobin cookie SERVERID insert indirect nocache server HAProxy1 1.1.1.1:80 check cookie haproxy1_1 server HAProxy2 3.3.3.3:80 check cookie haproxy2_1 backend mytest2_web mode http balance roundrobin cookie SERVERID insert indirect nocache server HAProxy1 1.1.1.1:80 check cookie haproxy1_3 server HAProxy2 3.3.3.3:80 check cookie haproxy2_3

Все отлично заработало. Казалось бы, можно радоваться, но тут сайты решено было переделать под работу через SSL. И начались проблемы.

Вернемся к началу и рассмотрим все с начала. Первое допущение — нам не нужно шифровать траффик между прокси-сервером и самим сайтом. Второе — нам не нужно заботиться о привязке сертификата к сайту, то есть у нас везде используются самоподписанные сертификаты.

Что нам нужно сделать? Сгенерировать и установить на нашем HAProxy сервере самоподписанный сертификат, тогда клиент, обращаясь на сайт, будет попадать на наш прокси-сервер, брать его сертификат, устанавливать защищенное соединение с сервером и дальше перенаправляться на веб-сайт. Причем для всех сайтов, находящихся за прокси-сервером, будет использоваться один сертификат.

Итак, приступим. Генерируем:

openssl req -new -x509 -nodes -out server.crt -keyout server.key

Записываем в один файл:

cat server.key > /etc/ssl/mytest.loc.pem cat server.crt >> /etc/ssl/mytest.loc.pem

И редактируем конфигурацию HAProxy(пример №3):

*frontend http_frontend bind *:80 mode http option httpclose acl is_mytest1 hdr_end(host) -i mytest1.loc use_backend mytest1_web if is_mytest1 acl is_mytest2 hdr_end(host) -i mytest2.loc use_backend mytest2_web if is_mytest2 backend mytest1_web mode http balance roundrobin cookie SERVERID insert indirect nocache server mytestweb1 192.168.1.5:80 check cookie mytestweb1 backend mytest2_web mode http balance roundrobin cookie SERVERID insert indirect nocache server mytestweb2 192.168.1.10:80 check cookie mytestweb2 frontend https_frontend bind :443 ssl crt /etc/ssl/mytest.loc.pem mode http option httpclose acl is_mytest1 hdr_end(host) -i mytest1.loc use_backend mytest1_web if is_mytest1 acl is_mytest2 hdr_end(host) -i mytest2.loc use_backend mytest2_web if is_mytest2

Кстати, проверять конфигурацию перед перезапуском — это очень полезная привычка:

haproxy -c -f /etc/haproxy/haproxy.cfg Configuration file is valid

Проверяем и видим, что все отлично работает.

Что ж, а теперь возьмем случай, когда на каждом сайте свой сертификат, причем не самоподписанный, а купленный. И в нем есть строгая привязка к имени сайта. В этом случае мы можем решить вопрос двумя способами: разместить сертификаты для сайтов на HAProxy сервере или проксировать TCP вместо HTTP. Но в обоих случаях мы не сможем обойтись одним IP адресом для двух наших сайтов.

Рассмотрим первый случай:

Все отличие данного случая от предыдущего(с самоподписанными сертификатами) только в том, что здесь нам придется слушать отдельные интерфейсы и выдавать сертификат в зависимости от интерфейса (пример №4):

*frontend http_frontend bind :80 mode http option httpclose acl is_mytest1 hdr_end(host) -i mytest1.loc use_backend mytest1_web if is_mytest1 acl is_mytest2 hdr_end(host) -i mytest2.loc use_backend mytest2_web if is_mytest2 backend mytest1_web mode http balance roundrobin cookie SERVERID insert indirect nocache server mytestweb1 192.168.1.5:80 check cookie mytestweb1 backend mytest2_web mode http balance roundrobin cookie SERVERID insert indirect nocache server mytestweb2 192.168.1.10:80 check cookie mytestweb2 frontend https_frontend_site1 bind 1.1.1.1:443 ssl crt /etc/ssl/mytest.loc1.pem mode http option httpclose acl is_mytest1 hdr_end(host) -i mytest1.loc use_backend mytest1_web if is_mytest1 frontend https_frontend_site2 bind 9.9.9.9:443 ssl crt /etc/ssl/mytest.loc2.pem mode http option httpclose acl is_mytest2 hdr_end(host) -i mytest2.loc use_backend mytest2_web if is_mytest2

Вроде все понятно, если траффик пришел на интерфейс с адресом 1.1.1.1, значит, клиент запрашивает сайт mytest1.loc. Значит, мы выдаем ему сертификат этого сайта и дальше проксируем на backend mytest1_web.

Во-втором случае мы пробрасываем полностью весь TCP-траффик, который пришел к нам на 443 порт. Это стоит сделать, например, тогда, когда вы по каким-либо причинам не хотите, чтоб сертификаты сайтов хранились на прокси сервере. Или, например, не доверяете внутренней сети между прокси и веб серверами.

Конфигурация HAProxy будет примерно следующая(пример №5):

frontend mytest1_frontend bind 1.1.1.1:443 mode tcp use_backend mytest1_webssl backend mytest1_webssl mode tcp option ssl-hello-chk server mytestweb 192.168.1.5:443 frontend mytest2_frontend bind 9.9.9.9:443 mode tcp use_backend mytest2_webssl backend mytest2_webssl mode tcp option ssl-hello-chk server mytestweb 192.168.1.10:443

Вроде вполне понятная конфигурация. Наверно, стоит сказать, что поскольку мы прокидываем весь TCP траффик, мы не можем анализировать его, и поэтому наличие любых access-lists в frontend части будет выдавать ошибку.

Настало время вернуться к нашей задаче с разделением web сайтов по разным городам. Для начала рассмотрим более простой случай:

Поскольку между HAProxy1 и HAProxy2 у нас интернет, то даже при использовании самоподписанных сертификатов мы не можем использовать HTTP PROXY MODE на HAProxy1, иначе теряется весь смысл в шифровании такого соединения. Будем использовать на HAProxy1 tcp mode, а на HAProxy2 http mode.

Конфигурация для HAProxy1 (пример №6):

*frontend https_frontend bind :443 mode tcp use_backend https_web backend https_web mode tcp option ssl-hello-chk server haproxy2 1.1.1.1:443

Конфигурация для HAProxy2 будет идентична конфигурации в примере №3ю

Настало время добавить вторую часть серверов:

Конфигурация для HAProxy1 (пример №7):

*frontend https_frontend bind :443 mode tcp use_backend https_web backend https_web mode tcp balance roundrobin option ssl-hello-chk server haproxy2 1.1.1.1:443 check server haproxy3 3.3.3.3:443 check

Все отличие данного примера от предыдущего — наличие балансировки и отказоустойчивости между HAProxy2 и HAProxy3, которые по нашему условию должны находиться в разных городах.

Что ж, последний пример будет в случае наличия несамоподписанных сертификатов. Предположим, что они установлены на HAProxy серверах — как в примере №4:

Конфигурация для HAProxy1 будет как в предыдущем примере, а для HAProxy2 — как в примере №4. Такая же для HAProxy3 с небольшими изменениями реальных адресов а frontend части.

Также стоит сказать, что можно все 3 HAProxy сервера настроить в TCP MODE — и это тоже будет работоспособное решение.

Ну и напоследок хотелось бы сказать: если кто-то знает какие-то принципиально отличающиеся решения для данной задачи, буду признателен, если вы поделитесь ими.

Небольшой апдейт. Мне тут подумалось, что если мы пробрасываем трафик, то нам незачем использовать на HAProxy2 и HAProxy3 набор различных IP адресов, гораздо проще просто использовать разные порты.

Давайте рассмотрим вот такую схему:

Конфигурация HAProxy1:

*frontend http_frontend bind :80 mode http option httpclose acl is_mytest1 hdr_end(host) -i mytest1.loc use_backend mytest1_web if is_mytest1 acl is_mytest2 hdr_end(host) -i mytest2.loc use_backend mytest2_web if is_mytest2 acl is_mytest3 hdr_end(host) -i mytest3.loc use_backend mytest3_web if is_mytest3 backend mytest1_web mode http balance roundrobin cookie SERVERID insert indirect nocache server mytestweb1 1.1.1.1:80 check cookie mytestweb1 server mytestweb1 2.2.2.2:80 check cookie mytestweb1 backend mytest2_web mode http balance roundrobin cookie SERVERID insert indirect nocache server mytestweb2 1.1.1.1:80 check cookie mytestweb2 server mytestweb2 2.2.2.2:80 check cookie mytestweb2 backend mytest3_web mode http balance roundrobin cookie SERVERID insert indirect nocache server mytestweb3 2.2.2.2:80 check cookie mytestweb3 frontend mytest1_frontend bind 3.3.3.3:443 mode tcp use_backend mytest_webssl1 backend mytest_webssl1 mode tcp balance roundrobin option ssl-hello-chk server mytestweb1 1.1.1.1:55551 server mytestweb2 2.2.2.2:55551 frontend mytest2_frontend bind 4.4.4.4:443 mode tcp use_backend mytest_webssl2 backend mytest_webssl2 mode tcp balance roundrobin option ssl-hello-chk server mytestweb1 1.1.1.1:55552 server mytestweb2 2.2.2.2:55552 frontend mytest3_frontend bind 5.5.5.5:443 mode tcp use_backend mytest_webssl3 backend mytest_webssl3 mode tcp balance roundrobin option ssl-hello-chk server mytestweb2 2.2.2.2:55553 И конфигурация HAProxy3:

*frontend http_frontend bind :80 mode http option httpclose acl is_mytest1 hdr_end(host) -i mytest1.loc use_backend mytest1_web if is_mytest1 acl is_mytest2 hdr_end(host) -i mytest2.loc use_backend mytest2_web if is_mytest2 acl is_mytest3 hdr_end(host) -i mytest3.loc use_backend mytest3_web if is_mytest3 frontend mytest1_frontend bind 2.2.2.2:55551 ssl crt /etc/ssl/mytest1.loc.pem mode http option httpclose option forwardfor reqadd X-Forwarded-Proto:\ https use_backend mytest1_web frontend mytest2_frontend bind 2.2.2.2:55552 ssl crt /etc/ssl/mytest2.loc.pem mode http option httpclose option forwardfor reqadd X-Forwarded-Proto:\ https use_backend mytest2_web frontend mytest3_frontend bind 2.2.2.2:55553 ssl crt /etc/ssl/mytest3.loc.pem mode http option httpclose option forwardfor reqadd X-Forwarded-Proto:\ https use_backend mytest3_web backend mytest1_web mode http balance roundrobin stats enable cookie SERVERID insert indirect nocache server mytestweb1 192.168.1.5:80 check cookie mytestweb1 backend mytest2_web mode http balance roundrobin stats enable cookie SERVERID insert indirect nocache server mytestweb2 192.168.1.10:80 check cookie mytestweb2 backend mytest3_web mode http balance roundrobin stats enable cookie SERVERID insert indirect nocache server mytestweb3 192.168.1.15:80 check cookie mytestweb3

У нас есть две разные хост площадки в разных городах. Одна находится за HAProxy2 и вторая за HAProxy3. И центральный прокси сервер, на котором лежит задача балансировки, при этом сайты и должны балансироваться, а сайт существует только лишь на одной площадке, поэтому доступ к нему должен только пробрасываться через прокси сервер.Все сайты должны быть доступны как по HTTP, так и по HTTPS с несамоподписанными сертификатами.

www.mytest1.loc
www.mytest2.loc
www.mytest3.loc
https://habr.com/ru/articles/244027/