Haproxy: различия между версиями
Материал из support.qbpro.ru
imported>Vix Нет описания правки |
imported>Vix Нет описания правки |
||
Строка 1: | Строка 1: | ||
* Установка: | |||
apt-get install haproxy | |||
* Пример конфигурации с разными каналами и хостами, как с '''https''' так и без, haproxy слушает как внешний канал так и внутренний '''VPN''': | |||
global | |||
log /dev/log local0 | |||
log /dev/log local1 notice | |||
user haproxy | |||
group haproxy | |||
daemon | |||
# Default SSL material locations | |||
ca-base /etc/ssl/certs | |||
crt-base /etc/ssl/private | |||
# Default ciphers to use on SSL-enabled listening sockets. | |||
# For more information, see ciphers(1SSL). This list is from: | |||
# https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/ | |||
# An alternative list with additional directives can be obtained from | |||
# https://mozilla.github.io/server-side-tls/ssl-config-generator/?server=haproxy | |||
ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS | |||
ssl-default-bind-options no-sslv3 | |||
## | |||
maxconn 2048 | |||
defaults | |||
log global | |||
option redispatch | |||
option tcp-smart-accept | |||
option tcp-smart-connect | |||
retries 3 | |||
maxconn 2000 | |||
timeout connect 5000 | |||
timeout check 3000 | |||
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 | |||
################################################## | |||
## balanser http & https examples config | |||
################################################## | |||
frontend http_frontend | |||
bind 92.19.132.73:80 | |||
mode http | |||
option forwardfor | |||
## -- for https web | |||
redirect scheme https if { hdr(Host) -i www.maindomen.ru } !{ ssl_fc } | |||
redirect scheme https if { hdr(Host) -i maindomen.ru } !{ ssl_fc } | |||
redirect scheme https if { hdr(Host) -i subdomen1.maindomen.ru } !{ ssl_fc } | |||
redirect scheme https if { hdr(Host) -i subdomen2.maindomen.ru } !{ ssl_fc } | |||
# | |||
## -- for http web | |||
acl host_subdomen3 hdr_beg(host) -i subdomen3.maindomen.ru | |||
acl host_subdomen4 hdr_beg(host) -i subdomen4.maindomen.ru | |||
# | |||
## -- for http rules web backens | |||
use_backend web_server1 if host_subdomen3 | |||
use_backend web_server0 if host_subdomen4 | |||
# | |||
## -- for http web backens | |||
backend web_server0 | |||
mode http | |||
reqadd X-Forwarded-Proto:\ http | |||
server subdomen3.maindomen.ru 10.5.1.7:8080 check | |||
# | |||
backend web_server1 | |||
mode http | |||
reqadd X-Forwarded-Proto:\ http | |||
server subdomen4.maindomen.ru 10.5.1.11:80 check | |||
# | |||
## -- for https frontend | |||
frontend https_frontend_ssl_pass | |||
bind 92.19.132.73:443 | |||
mode tcp | |||
default_backend web_server_tcp | |||
# | |||
## -- for https web backens | |||
backend web_server_tcp | |||
mode tcp | |||
balance roundrobin | |||
server maindomen.ru 10.5.1.7:443 send-proxy | |||
server subdomen1.maindomen.ru 10.5.1.7:443 send-proxy | |||
server subdomen2.maindomen.ru 10.5.1.7:443 send-proxy | |||
# | |||
## -- vpn fronted | |||
frontend http_frontend_vpn | |||
bind 10.0.8.1:80 | |||
mode http | |||
option forwardfor | |||
# | |||
## -- for http vpn web | |||
acl host_devhost hdr_beg(host) -i devhost.ldomen.local | |||
acl host_libarh hdr_beg(host) -i libarh.ldomen.local | |||
# | |||
## -- for http rules web backens | |||
use_backend web_server_vpn1 if host_devhost | |||
use_backend web_server_vpn0 if host_libarh | |||
## -- for http vpn web backens | |||
backend web_server_vpn0 | |||
mode http | |||
reqadd X-Forwarded-Proto:\ http | |||
server libarh.ldomen.local 10.5.1.7:80 check | |||
backend web_server_vpn1 | |||
mode http | |||
reqadd X-Forwarded-Proto:\ http | |||
server devhost.ldomen.local 10.5.1.9:80 check | |||
* После изменений перезапуск haproxy... | |||
'''ИСТОЧНИКИ:''' | '''ИСТОЧНИКИ:''' |
Версия от 01:22, 25 марта 2019
- Установка:
apt-get install haproxy
- Пример конфигурации с разными каналами и хостами, как с https так и без, haproxy слушает как внешний канал так и внутренний VPN:
global log /dev/log local0 log /dev/log local1 notice user haproxy group haproxy daemon # Default SSL material locations ca-base /etc/ssl/certs crt-base /etc/ssl/private # Default ciphers to use on SSL-enabled listening sockets. # For more information, see ciphers(1SSL). This list is from: # https://hynek.me/articles/hardening-your-web-servers-ssl-ciphers/ # An alternative list with additional directives can be obtained from # https://mozilla.github.io/server-side-tls/ssl-config-generator/?server=haproxy ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:RSA+AESGCM:RSA+AES:!aNULL:!MD5:!DSS ssl-default-bind-options no-sslv3 ## maxconn 2048 defaults log global option redispatch option tcp-smart-accept option tcp-smart-connect retries 3 maxconn 2000 timeout connect 5000 timeout check 3000 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 ################################################## ## balanser http & https examples config ################################################## frontend http_frontend bind 92.19.132.73:80 mode http option forwardfor ## -- for https web redirect scheme https if { hdr(Host) -i www.maindomen.ru } !{ ssl_fc } redirect scheme https if { hdr(Host) -i maindomen.ru } !{ ssl_fc } redirect scheme https if { hdr(Host) -i subdomen1.maindomen.ru } !{ ssl_fc } redirect scheme https if { hdr(Host) -i subdomen2.maindomen.ru } !{ ssl_fc } # ## -- for http web acl host_subdomen3 hdr_beg(host) -i subdomen3.maindomen.ru acl host_subdomen4 hdr_beg(host) -i subdomen4.maindomen.ru # ## -- for http rules web backens use_backend web_server1 if host_subdomen3 use_backend web_server0 if host_subdomen4 # ## -- for http web backens backend web_server0 mode http reqadd X-Forwarded-Proto:\ http server subdomen3.maindomen.ru 10.5.1.7:8080 check # backend web_server1 mode http reqadd X-Forwarded-Proto:\ http server subdomen4.maindomen.ru 10.5.1.11:80 check # ## -- for https frontend frontend https_frontend_ssl_pass bind 92.19.132.73:443 mode tcp default_backend web_server_tcp # ## -- for https web backens backend web_server_tcp mode tcp balance roundrobin server maindomen.ru 10.5.1.7:443 send-proxy server subdomen1.maindomen.ru 10.5.1.7:443 send-proxy server subdomen2.maindomen.ru 10.5.1.7:443 send-proxy # ## -- vpn fronted frontend http_frontend_vpn bind 10.0.8.1:80 mode http option forwardfor # ## -- for http vpn web acl host_devhost hdr_beg(host) -i devhost.ldomen.local acl host_libarh hdr_beg(host) -i libarh.ldomen.local
# ## -- for http rules web backens use_backend web_server_vpn1 if host_devhost use_backend web_server_vpn0 if host_libarh
## -- for http vpn web backens backend web_server_vpn0 mode http reqadd X-Forwarded-Proto:\ http server libarh.ldomen.local 10.5.1.7:80 check
backend web_server_vpn1 mode http reqadd X-Forwarded-Proto:\ http server devhost.ldomen.local 10.5.1.9:80 check
- После изменений перезапуск haproxy...
ИСТОЧНИКИ:
- официальный сайт - en
- Описание конфигурационного файла HAProxy — haproxy.cfg
- haproxy+node.js
- Haproxy manual - en
- защита от взлома
- работаем с node
- еще пример с node.js
- HAProxy Configuration Manual с частичным переводом
- Получаем IP-адреса HTTPS-клиентов с HAProxy (frontend) на Nginx (backend) в режимах HTTP и TCP-балансировки
- Введение в HAProxy и принципы распределения нагрузки
- How to Use HAProxy for Load Balancing
- HAProxy перенаправляет http на https (ssl)
- Примеры настройки HaProxy
- Описание конфигурационного файла HAProxy
- Установка и настройка HAProxy на Debian/Ubuntu