I have my haproxy container called 'proxy_container' running on port 80 on my localhost. With two other containers called 'client_container' which is just an html file, and 'server_container' which is a nodejs basic api I wrote. All connected to a single docker network called 'appnet'.
docker ps:
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f6fa17dbd444 ebdc86ff4850 "docker-entrypoint.s…" About a minute ago Up About a minute 80/tcp server_container
32ebf717e9de 8657ad512e31 "/docker-entrypoint.…" About a minute ago Up About a minute 80/tcp client_container
bc3f94b668cd bd8334ffaaad "docker-entrypoint.s…" About a minute ago Up About a minute 0.0.0.0:80->80/tcp proxy_container
Here is my haproxy.cfg file:
global
daemon
maxconn 2000
stats socket /var/run/haproxy.sock mode 777
resolvers docker
nameserver dns "${DNS_TCP_ADDR}:${DNS_TCP_PORT}" #127.0.0.11:53
defaults
mode http
option dontlognull
option forwardfor
option httpclose
option httplog
retries 3
timeout check 5s
timeout client 5s
timeout connect 10s
timeout server 10s
frontend main
bind *:80
mode http
option http-server-close
option forceclose
timeout client 60s
timeout connect 10s
timeout server 1m
acl url_ui path_beg /home
acl url_api path_beg /api
use_backend ui if url_ui
use_backend api if url_api
#deafult_backend ui
backend api
# mode http
# server api server_container
server api server_container.appnet:80 check resolvers docker resolve-prefer ipv4
backend ui
# mode http
# server client client_container
server client client_container.appnet:80 check resolvers docker resolve-prefer ipv4
The default_backend ui line that I commented out worked fine when typing 0.0.0.0/ in my browser. I want to change my config so that 0.0.0.0/home directs me to backend 'ui', and 0.0.0.0/api directs me to backend 'api'.
Side question: for the api path how would my nodejs api paths work alongside these configurations I want?