• 5

A PHP Error was encountered

Severity: Notice

Message: Undefined index: userid

Filename: views/question.php

Line Number: 191


File: /home/prodcxja/public_html/questions/application/views/question.php
Line: 191
Function: _error_handler

File: /home/prodcxja/public_html/questions/application/controllers/Questions.php
Line: 433
Function: view

File: /home/prodcxja/public_html/questions/index.php
Line: 315
Function: require_once

name Punditsdkoslkdosdkoskdo

Haproxy redirection to Docker container

We have Haproxy in AWS and it will redirect all the traffic to our development environment.Recently i have deployed 2 docker container in one of the Ec2 instance. I would like to access those container via Haproxy. Guide me how to configure the haproxy redirect to container. Find the sample config below.

    log /dev/log    local0
    log /dev/log    local1 notice
    stats timeout 30s
    maxconn 4096
    user haproxy
    group haproxy
    log     global
    mode    tcp
    option  tcplog
    option  dontlognull
    timeout connect 15s
    timeout client  15s
    timeout server  15s

frontend http_80_frontend
    bind *:80
    mode http
    redirect scheme https code 301 if !{ ssl_fc }

frontend https_443_frontend
    bind *:443
    option tcplog
    mode tcp
    acl tls req.ssl_hello_type 1
    tcp-request inspect-delay 5s
    tcp-request content accept if tls
    acl container01 req.ssl_sni -i container01.test.com
    use_backend container01 if container01
    acl container02 req.ssl_sni -i container02.test.com
    use_backend container02 if container02

backend container01
    mode tcp
    option ssl-hello-chk
    server container01 check
backend container02
    mode tcp
    option ssl-hello-chk
    server container02 check 

If you are running these containers as a service (would recommend depending on purpose) they can be put behind the Docker HAProxy container. As straightforward as making the service, starting the containers, starting the HAProxy container and configuring it to point at the other two containers and the specific port. This is one of the tutorials that shows how to do it with the GUI on Docker Cloud - however all of the same concepts apply with the CLI https://docs.docker.com/docker-cloud/apps/load-balance-hello-world/#launch-the-web-service

  • 0
Reply Report
      • 1
    • Thanks, My requirement is not to host haproxy container, I have a haproxy already hosted in aws. I just need to add a respective config in haproxy as above.

Trending Tags