Commit 9a5d7776fd5fff14577eb572ce2654999480bfb2

Authored by Igor Kulikov
1 parent dc61052b

MSA Docker: tb-node REST API loadbalancing.

... ... @@ -134,9 +134,6 @@ services:
134 134 image: "${DOCKER_REPO}/${WEB_UI_DOCKER_NAME}:${TB_VERSION}"
135 135 ports:
136 136 - "8080"
137   - environment:
138   - TB_HOST: tb1
139   - TB_PORT: 8080
140 137 env_file:
141 138 - tb-web-ui.env
142 139 tb-web-ui2:
... ... @@ -144,12 +141,9 @@ services:
144 141 image: "${DOCKER_REPO}/${WEB_UI_DOCKER_NAME}:${TB_VERSION}"
145 142 ports:
146 143 - "8080"
147   - environment:
148   - TB_HOST: tb2
149   - TB_PORT: 8080
150 144 env_file:
151 145 - tb-web-ui.env
152   - web:
  146 + haproxy:
153 147 restart: always
154 148 container_name: haproxy-certbot
155 149 image: nmarus/haproxy-certbot
... ... @@ -159,6 +153,7 @@ services:
159 153 - ./haproxy/certs.d:/usr/local/etc/haproxy/certs.d
160 154 ports:
161 155 - "80:80"
  156 + - "8080"
162 157 - "443:443"
163 158 - "1883:1883"
164 159 - "9999:9999"
... ... @@ -168,8 +163,11 @@ services:
168 163 HTTP_PORT: 80
169 164 HTTPS_PORT: 443
170 165 MQTT_PORT: 1883
  166 + TB_API_PORT: 8080
171 167 FORCE_HTTPS_REDIRECT: "false"
172 168 links:
  169 + - tb1
  170 + - tb2
173 171 - tb-web-ui1
174 172 - tb-web-ui2
175 173 - tb-mqtt-transport1
... ...
... ... @@ -69,6 +69,11 @@ frontend https_in
69 69
70 70 default_backend tb-web-backend
71 71
  72 +frontend http-api-in
  73 + bind *:${TB_API_PORT}
  74 +
  75 + default_backend tb-api-backend
  76 +
72 77 backend letsencrypt_http
73 78 server letsencrypt_http_srv 127.0.0.1:8080
74 79
... ... @@ -86,3 +91,10 @@ backend tb-http-backend
86 91 option log-health-checks
87 92 server tbHttp1 tb-http-transport1:8081 check
88 93 server tbHttp2 tb-http-transport2:8081 check
  94 +
  95 +backend tb-api-backend
  96 + balance leastconn
  97 + option tcp-check
  98 + option log-health-checks
  99 + server tbApi1 tb1:8080 check
  100 + server tbApi2 tb2:8080 check
... ...
1 1
2 2 HTTP_BIND_ADDRESS=0.0.0.0
3 3 HTTP_BIND_PORT=8080
4   -TB_HOST=localhost
  4 +TB_HOST=haproxy
5 5 TB_PORT=8080
6 6 LOGGER_LEVEL=info
7 7 LOG_FOLDER=logs
... ...