global
log /dev/log local0
log /dev/log local1 notice
chroot /var/lib/haproxy
stats socket /run/haproxy/admin.sock mode 660 level admin
stats timeout 30s
user haproxy
group haproxy
daemon
defaults
log global
mode tcp
# option httplog
option tcplog
option dontlognull
timeout connect 5000
timeout client 50000
timeout server 50000
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
# настройки frontend для http. 192.168.77.7:80 - адрес на котором будем слушать запросы, строки stats - для отображения странички статистики с авторизацией http://192.168.77.7/haproxy, forwardfor - передавать ip запрашивающего,
frontend http_frontend
mode http
option httplog
bind 192.168.77.7:80
stats enable
stats uri /haproxy
stats realm Haproxy\ Statistics
stats auth user:Password
option forwardfor
#Создаем ACL для домена и заворачиваем на backend
acl host_wiki hdr(host) -i onedayadmin.sytes.net
use_backend http_wiki if host_wiki
#Редиректим http на https для одного доменного имени
redirect scheme https code 301 if { hdr(Host) -i 1c.beerhoff.beer } !{ ssl_fc }
#Создаем backend который будет отправлять запросы на наш локальный сервер, в данном случае это web на этой же машине.
backend http_wiki
mode http
option forwardfor
server wiki 192.168.77.7:8080
#Создаем frontend для https
frontend https
bind 192.168.77.7:443
option forwardfor
mode tcp
acl tls req.ssl_hello_type 1
tcp-request inspect-delay 5s
tcp-request content accept if tls
#локаничным способом сделаем acl + перенаправление на backend
use_backend nginx if { req_ssl_sni -i www.onedayadmin.sytes.net }
use_backend nginx if { req_ssl_sni -i onedayadmin.sytes.net }
use_backend matrix if { req_ssl_sni -i matrix.beerhoff.beer }
use_backend 1Chttps if { req_ssl_sni -i 1c.beerhoff.beer }
default_backend ocserv
#Опишем backend-ы
backend nginx
mode tcp
option ssl-hello-chk
server nginx 127.0.0.1:443 check
backend matrix
mode tcp
option ssl-hello-chk
server matrix 192.168.77.9:443 check
backend 1Chttps
mode tcp
option tcplog
option ssl-hello-chk
server 1C 192.168.77.250:443

