KARAF / karaf star
2022-12-17
Open
#14 HAProxy 도커 만들기 star
2022-12-17 Open
Tasks

HAProxy용 우분투 도커 생성#

docker run -d -t --name ssemiyaproxy \
-p 19080:80 \
-p 10443:443 \
-p 19100:9000 \
-p 11722:22 \
dsubuntu:16.04


export PS1='
\u@docker-ssemiyaproxy:[$PWD]
$ ';

도커 접속 및 HAProxy 설치#

ssh root@10.9.0.1 -p 11722

root@docker-ssemiyaproxy:[/root]
$ apt install haproxy

haproxy.cfg 생성#

root@docker-ssemiyaproxy:[/etc/haproxy]
$ haproxy -f /etc/haproxy/haproxy.cfg -c
Configuration file is valid

HAProxy 재시작#

root@docker-ssemiyaproxy:[/Log]
$ service haproxy restart

상태확인#

http://10.9.0.1:19100/haproxy_stats

서비스 테스트#

http://10.9.0.1:19080/

haproxy.cfg#

global
    # log /dev/log    local0
    # log /dev/log    local1 notice
    log /Log/haproxy    local0
    log /Log/haproxy    local1 notice
    chroot /var/lib/haproxy
    stats socket /run/haproxy/admin.sock mode 660 level admin
    stats timeout 30s
    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/
    ssl-default-bind-ciphers ECDH+AESGCM:DH+AESGCM:ECDH+AES256:DH+AES256:ECDH+AES128:DH+AES:ECDH+3DES:DH+3DES:RSA+AESGCM:RSA+AES:RSA+3DES:!aNULL:!MD5:!DSS
    ssl-default-bind-options no-sslv3

defaults
    log        global # 로그는 global 설정을 따른다
    mode    http # http 프로토콜 사용
    option    httplog # 로그 디텔일을 높임
    option    dontlognull # 로그 비대화 방지를 위해 probe같은 잡다한 기록은 남기지 않음
        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 LOADBALANCER-01
    bind  172.17.0.7:80 # 대표 IP Address
    mode http
    default_backend TESTSERVICE-WAS

backend TESTSERVICE-WAS
        balance roundrobin
        server was1 172.17.0.3:8080 check # WAS #1
        server was2 172.17.0.6:8080 check # WAS #2
        option httpchk

#listen #프론트/밴엔드의 연결의 포트/옵션을 정의함. tcp제어나 proxy에 주로 사용
listen stats # stats란 이름으로 리슨 지정
    bind *:9000 # 접속포트 지정
    mode http

    stats enable
    stats realm Haproxy Statistics
    stats uri /haproxy_stats # stat을 제공할 url
    #stats auth Username:Password # 인증이 필요하면 추가한다
Issue Sharer
Comment 0

Add a comment
New subtask
Assignee
No assignee
Due date
No due date
Label
docker ubuntu infra
Comment 0