traefik not respecting frontend rule
up vote
0
down vote
favorite
I am trying to deploy multiple apps on my docker host and have traefik route traffic based on hostnames to the different apps
I am using docker-compose for all my docker containers
Here is my traeffik.yaml file
version: '3.5'
services:
traefik:
image: traefik
container_name: traefik
command: --api --docker
networks:
- traefik_network
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
traefik_network:
name: traefik_network
here is my wpapp1.yaml file
version: '3.5'
services:
mysql:
image: mysql:5.7
volumes:
- wpapp1_mysql:/var/lib/mysql
restart: always
container_name: wpapp1_mysql
networks:
- traefik_network
environment:
MYSQL_ROOT_PASSWORD: wpapp1
MYSQL_DATABASE: wpapp1
MYSQL_USER: wpapp1
MYSQL_PASSWORD: wpapp1
wordpress:
depends_on:
- mysql
image: wordpress:latest
volumes:
- wpapp1_wordpress:/var/www/html
restart: always
container_name: wpapp1_wordpress
networks:
- traefik_network
labels:
- "traefik.frontend.rule=Host:wpapp1.example.com"
- "traefik.port=80"
- "traefik.docker.network=traefik_network"
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_USER: wpapp1
WORDPRESS_DB_PASSWORD: wpapp1
volumes:
wpapp1_mysql:
name: wpapp1_mysql
wpapp1_wordpress:
name: wpapp1_wordpress
networks:
traefik_network:
external:
name: traefik_network
and here is my wpapp2.yaml file
version: '3.5'
services:
mysql:
image: mysql:5.7
volumes:
- wpapp2_mysql:/var/lib/mysql
restart: always
container_name: wpapp2_mysql
networks:
- traefik_network
environment:
MYSQL_ROOT_PASSWORD: wpapp2
MYSQL_DATABASE: wpapp2
MYSQL_USER: wpapp2
MYSQL_PASSWORD: wpapp2
wordpress:
depends_on:
- mysql
image: wordpress:latest
volumes:
- wpapp2_wordpress:/var/www/html
restart: always
container_name: wpapp2_wordpress
networks:
- traefik_network
labels:
- "traefik.frontend.rule=Host:wpapp2.example.com"
- "traefik.port=80"
- "traefik.docker.network=traefik_network"
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_USER: wpapp2
WORDPRESS_DB_PASSWORD: wpapp2
volumes:
wpapp2_mysql:
name: wpapp2_mysql
wpapp2_wordpress:
name: wpapp2_wordpress
networks:
traefik_network:
external:
name: traefik_network
So now i expect traefik to route based on the hostnames wpapp1.example.com and wpapp2.example.com BUT traefik is loadbalancing traffic!!!
So when i go to http:/wpapp1.example.com, traefik is loadbalancing it between the two apps and same for the other hostnames. Now sure what is going on here since i specifically add the traefik.frontend.rule
I mean how in the hell is that happening?
I have spent hours to figure what is going on and before i go insane i decided to some here to get some help on what is going on here.
docker docker-compose reverse-proxy traefik
add a comment |
up vote
0
down vote
favorite
I am trying to deploy multiple apps on my docker host and have traefik route traffic based on hostnames to the different apps
I am using docker-compose for all my docker containers
Here is my traeffik.yaml file
version: '3.5'
services:
traefik:
image: traefik
container_name: traefik
command: --api --docker
networks:
- traefik_network
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
traefik_network:
name: traefik_network
here is my wpapp1.yaml file
version: '3.5'
services:
mysql:
image: mysql:5.7
volumes:
- wpapp1_mysql:/var/lib/mysql
restart: always
container_name: wpapp1_mysql
networks:
- traefik_network
environment:
MYSQL_ROOT_PASSWORD: wpapp1
MYSQL_DATABASE: wpapp1
MYSQL_USER: wpapp1
MYSQL_PASSWORD: wpapp1
wordpress:
depends_on:
- mysql
image: wordpress:latest
volumes:
- wpapp1_wordpress:/var/www/html
restart: always
container_name: wpapp1_wordpress
networks:
- traefik_network
labels:
- "traefik.frontend.rule=Host:wpapp1.example.com"
- "traefik.port=80"
- "traefik.docker.network=traefik_network"
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_USER: wpapp1
WORDPRESS_DB_PASSWORD: wpapp1
volumes:
wpapp1_mysql:
name: wpapp1_mysql
wpapp1_wordpress:
name: wpapp1_wordpress
networks:
traefik_network:
external:
name: traefik_network
and here is my wpapp2.yaml file
version: '3.5'
services:
mysql:
image: mysql:5.7
volumes:
- wpapp2_mysql:/var/lib/mysql
restart: always
container_name: wpapp2_mysql
networks:
- traefik_network
environment:
MYSQL_ROOT_PASSWORD: wpapp2
MYSQL_DATABASE: wpapp2
MYSQL_USER: wpapp2
MYSQL_PASSWORD: wpapp2
wordpress:
depends_on:
- mysql
image: wordpress:latest
volumes:
- wpapp2_wordpress:/var/www/html
restart: always
container_name: wpapp2_wordpress
networks:
- traefik_network
labels:
- "traefik.frontend.rule=Host:wpapp2.example.com"
- "traefik.port=80"
- "traefik.docker.network=traefik_network"
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_USER: wpapp2
WORDPRESS_DB_PASSWORD: wpapp2
volumes:
wpapp2_mysql:
name: wpapp2_mysql
wpapp2_wordpress:
name: wpapp2_wordpress
networks:
traefik_network:
external:
name: traefik_network
So now i expect traefik to route based on the hostnames wpapp1.example.com and wpapp2.example.com BUT traefik is loadbalancing traffic!!!
So when i go to http:/wpapp1.example.com, traefik is loadbalancing it between the two apps and same for the other hostnames. Now sure what is going on here since i specifically add the traefik.frontend.rule
I mean how in the hell is that happening?
I have spent hours to figure what is going on and before i go insane i decided to some here to get some help on what is going on here.
docker docker-compose reverse-proxy traefik
Are you sure it's traefik load balancing and not WordPress load balancing to the duplicate mysql instances in the same traefik network?
– BMitch
Nov 10 at 16:38
well not sure..what do i do to not make that happen? lets assume its wordpress doing that..because i just checked logs and i see that even database are getting loadbalanced too..i mean i have docker-compose so why isn't there separation between the apps? am not like exposing ports on host so not sure why docker is behaving like this
– uberrebu
Nov 10 at 16:43
Put mysql on a different network, easiest is to not put it on a network at all and let compose make the default network. Then put WordPress on both the traefik and default networks (the default network name is "default").
– BMitch
Nov 10 at 16:47
i have tried using different networks for the apps..but then traefik does not work when i have apps in another network..so anyone that can help with best way to segment these apps behind traefik..will appreciate it
– uberrebu
Nov 10 at 16:47
i will like to give my own network names rather than use default network..and when i tried doing that traefik did not pick up anything and was getting gateway timeouts..so how can i specify different networks for mysql and then have wordpress on traefik network and the custom network for the different apps?
– uberrebu
Nov 10 at 16:49
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I am trying to deploy multiple apps on my docker host and have traefik route traffic based on hostnames to the different apps
I am using docker-compose for all my docker containers
Here is my traeffik.yaml file
version: '3.5'
services:
traefik:
image: traefik
container_name: traefik
command: --api --docker
networks:
- traefik_network
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
traefik_network:
name: traefik_network
here is my wpapp1.yaml file
version: '3.5'
services:
mysql:
image: mysql:5.7
volumes:
- wpapp1_mysql:/var/lib/mysql
restart: always
container_name: wpapp1_mysql
networks:
- traefik_network
environment:
MYSQL_ROOT_PASSWORD: wpapp1
MYSQL_DATABASE: wpapp1
MYSQL_USER: wpapp1
MYSQL_PASSWORD: wpapp1
wordpress:
depends_on:
- mysql
image: wordpress:latest
volumes:
- wpapp1_wordpress:/var/www/html
restart: always
container_name: wpapp1_wordpress
networks:
- traefik_network
labels:
- "traefik.frontend.rule=Host:wpapp1.example.com"
- "traefik.port=80"
- "traefik.docker.network=traefik_network"
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_USER: wpapp1
WORDPRESS_DB_PASSWORD: wpapp1
volumes:
wpapp1_mysql:
name: wpapp1_mysql
wpapp1_wordpress:
name: wpapp1_wordpress
networks:
traefik_network:
external:
name: traefik_network
and here is my wpapp2.yaml file
version: '3.5'
services:
mysql:
image: mysql:5.7
volumes:
- wpapp2_mysql:/var/lib/mysql
restart: always
container_name: wpapp2_mysql
networks:
- traefik_network
environment:
MYSQL_ROOT_PASSWORD: wpapp2
MYSQL_DATABASE: wpapp2
MYSQL_USER: wpapp2
MYSQL_PASSWORD: wpapp2
wordpress:
depends_on:
- mysql
image: wordpress:latest
volumes:
- wpapp2_wordpress:/var/www/html
restart: always
container_name: wpapp2_wordpress
networks:
- traefik_network
labels:
- "traefik.frontend.rule=Host:wpapp2.example.com"
- "traefik.port=80"
- "traefik.docker.network=traefik_network"
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_USER: wpapp2
WORDPRESS_DB_PASSWORD: wpapp2
volumes:
wpapp2_mysql:
name: wpapp2_mysql
wpapp2_wordpress:
name: wpapp2_wordpress
networks:
traefik_network:
external:
name: traefik_network
So now i expect traefik to route based on the hostnames wpapp1.example.com and wpapp2.example.com BUT traefik is loadbalancing traffic!!!
So when i go to http:/wpapp1.example.com, traefik is loadbalancing it between the two apps and same for the other hostnames. Now sure what is going on here since i specifically add the traefik.frontend.rule
I mean how in the hell is that happening?
I have spent hours to figure what is going on and before i go insane i decided to some here to get some help on what is going on here.
docker docker-compose reverse-proxy traefik
I am trying to deploy multiple apps on my docker host and have traefik route traffic based on hostnames to the different apps
I am using docker-compose for all my docker containers
Here is my traeffik.yaml file
version: '3.5'
services:
traefik:
image: traefik
container_name: traefik
command: --api --docker
networks:
- traefik_network
ports:
- "80:80"
- "8080:8080"
volumes:
- /var/run/docker.sock:/var/run/docker.sock
networks:
traefik_network:
name: traefik_network
here is my wpapp1.yaml file
version: '3.5'
services:
mysql:
image: mysql:5.7
volumes:
- wpapp1_mysql:/var/lib/mysql
restart: always
container_name: wpapp1_mysql
networks:
- traefik_network
environment:
MYSQL_ROOT_PASSWORD: wpapp1
MYSQL_DATABASE: wpapp1
MYSQL_USER: wpapp1
MYSQL_PASSWORD: wpapp1
wordpress:
depends_on:
- mysql
image: wordpress:latest
volumes:
- wpapp1_wordpress:/var/www/html
restart: always
container_name: wpapp1_wordpress
networks:
- traefik_network
labels:
- "traefik.frontend.rule=Host:wpapp1.example.com"
- "traefik.port=80"
- "traefik.docker.network=traefik_network"
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_USER: wpapp1
WORDPRESS_DB_PASSWORD: wpapp1
volumes:
wpapp1_mysql:
name: wpapp1_mysql
wpapp1_wordpress:
name: wpapp1_wordpress
networks:
traefik_network:
external:
name: traefik_network
and here is my wpapp2.yaml file
version: '3.5'
services:
mysql:
image: mysql:5.7
volumes:
- wpapp2_mysql:/var/lib/mysql
restart: always
container_name: wpapp2_mysql
networks:
- traefik_network
environment:
MYSQL_ROOT_PASSWORD: wpapp2
MYSQL_DATABASE: wpapp2
MYSQL_USER: wpapp2
MYSQL_PASSWORD: wpapp2
wordpress:
depends_on:
- mysql
image: wordpress:latest
volumes:
- wpapp2_wordpress:/var/www/html
restart: always
container_name: wpapp2_wordpress
networks:
- traefik_network
labels:
- "traefik.frontend.rule=Host:wpapp2.example.com"
- "traefik.port=80"
- "traefik.docker.network=traefik_network"
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_USER: wpapp2
WORDPRESS_DB_PASSWORD: wpapp2
volumes:
wpapp2_mysql:
name: wpapp2_mysql
wpapp2_wordpress:
name: wpapp2_wordpress
networks:
traefik_network:
external:
name: traefik_network
So now i expect traefik to route based on the hostnames wpapp1.example.com and wpapp2.example.com BUT traefik is loadbalancing traffic!!!
So when i go to http:/wpapp1.example.com, traefik is loadbalancing it between the two apps and same for the other hostnames. Now sure what is going on here since i specifically add the traefik.frontend.rule
I mean how in the hell is that happening?
I have spent hours to figure what is going on and before i go insane i decided to some here to get some help on what is going on here.
docker docker-compose reverse-proxy traefik
docker docker-compose reverse-proxy traefik
edited Nov 10 at 16:22
asked Nov 10 at 15:59
uberrebu
115110
115110
Are you sure it's traefik load balancing and not WordPress load balancing to the duplicate mysql instances in the same traefik network?
– BMitch
Nov 10 at 16:38
well not sure..what do i do to not make that happen? lets assume its wordpress doing that..because i just checked logs and i see that even database are getting loadbalanced too..i mean i have docker-compose so why isn't there separation between the apps? am not like exposing ports on host so not sure why docker is behaving like this
– uberrebu
Nov 10 at 16:43
Put mysql on a different network, easiest is to not put it on a network at all and let compose make the default network. Then put WordPress on both the traefik and default networks (the default network name is "default").
– BMitch
Nov 10 at 16:47
i have tried using different networks for the apps..but then traefik does not work when i have apps in another network..so anyone that can help with best way to segment these apps behind traefik..will appreciate it
– uberrebu
Nov 10 at 16:47
i will like to give my own network names rather than use default network..and when i tried doing that traefik did not pick up anything and was getting gateway timeouts..so how can i specify different networks for mysql and then have wordpress on traefik network and the custom network for the different apps?
– uberrebu
Nov 10 at 16:49
add a comment |
Are you sure it's traefik load balancing and not WordPress load balancing to the duplicate mysql instances in the same traefik network?
– BMitch
Nov 10 at 16:38
well not sure..what do i do to not make that happen? lets assume its wordpress doing that..because i just checked logs and i see that even database are getting loadbalanced too..i mean i have docker-compose so why isn't there separation between the apps? am not like exposing ports on host so not sure why docker is behaving like this
– uberrebu
Nov 10 at 16:43
Put mysql on a different network, easiest is to not put it on a network at all and let compose make the default network. Then put WordPress on both the traefik and default networks (the default network name is "default").
– BMitch
Nov 10 at 16:47
i have tried using different networks for the apps..but then traefik does not work when i have apps in another network..so anyone that can help with best way to segment these apps behind traefik..will appreciate it
– uberrebu
Nov 10 at 16:47
i will like to give my own network names rather than use default network..and when i tried doing that traefik did not pick up anything and was getting gateway timeouts..so how can i specify different networks for mysql and then have wordpress on traefik network and the custom network for the different apps?
– uberrebu
Nov 10 at 16:49
Are you sure it's traefik load balancing and not WordPress load balancing to the duplicate mysql instances in the same traefik network?
– BMitch
Nov 10 at 16:38
Are you sure it's traefik load balancing and not WordPress load balancing to the duplicate mysql instances in the same traefik network?
– BMitch
Nov 10 at 16:38
well not sure..what do i do to not make that happen? lets assume its wordpress doing that..because i just checked logs and i see that even database are getting loadbalanced too..i mean i have docker-compose so why isn't there separation between the apps? am not like exposing ports on host so not sure why docker is behaving like this
– uberrebu
Nov 10 at 16:43
well not sure..what do i do to not make that happen? lets assume its wordpress doing that..because i just checked logs and i see that even database are getting loadbalanced too..i mean i have docker-compose so why isn't there separation between the apps? am not like exposing ports on host so not sure why docker is behaving like this
– uberrebu
Nov 10 at 16:43
Put mysql on a different network, easiest is to not put it on a network at all and let compose make the default network. Then put WordPress on both the traefik and default networks (the default network name is "default").
– BMitch
Nov 10 at 16:47
Put mysql on a different network, easiest is to not put it on a network at all and let compose make the default network. Then put WordPress on both the traefik and default networks (the default network name is "default").
– BMitch
Nov 10 at 16:47
i have tried using different networks for the apps..but then traefik does not work when i have apps in another network..so anyone that can help with best way to segment these apps behind traefik..will appreciate it
– uberrebu
Nov 10 at 16:47
i have tried using different networks for the apps..but then traefik does not work when i have apps in another network..so anyone that can help with best way to segment these apps behind traefik..will appreciate it
– uberrebu
Nov 10 at 16:47
i will like to give my own network names rather than use default network..and when i tried doing that traefik did not pick up anything and was getting gateway timeouts..so how can i specify different networks for mysql and then have wordpress on traefik network and the custom network for the different apps?
– uberrebu
Nov 10 at 16:49
i will like to give my own network names rather than use default network..and when i tried doing that traefik did not pick up anything and was getting gateway timeouts..so how can i specify different networks for mysql and then have wordpress on traefik network and the custom network for the different apps?
– uberrebu
Nov 10 at 16:49
add a comment |
1 Answer
1
active
oldest
votes
up vote
1
down vote
accepted
Put your database on a different network. Otherwise WordPress will RR load balance to the two mysql instances in the same docker network (that's the expected behavior when you have two containers with the same alias on the same network). You can do that with the default network:
version: '3.5'
services:
mysql:
image: mysql:5.7
volumes:
- mysql:/var/lib/mysql
restart: unless-stopped
networks:
- db
environment:
MYSQL_ROOT_PASSWORD: wpapp
MYSQL_DATABASE: wpapp
MYSQL_USER: wpapp
MYSQL_PASSWORD: wpapp
wordpress:
depends_on:
- mysql
image: wordpress:latest
volumes:
- wordpress:/var/www/html
restart: unless-stopped
networks:
- traefik
- db
labels:
- "traefik.frontend.rule=Host:wpapp1.example.com"
- "traefik.port=80"
- "traefik.docker.network=traefik_network"
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_USER: wpapp
WORDPRESS_DB_PASSWORD: wpapp
volumes:
mysql:
wordpress:
networks:
db:
traefik:
external:
name: traefik_network
can i use custom network name rather than usedefault? can i use likedb_networkor something custom?
– uberrebu
Nov 10 at 16:57
making it unique is not a problem...i think i just did that and still getting issues
– uberrebu
Nov 10 at 16:59
Updated with a db network name
– BMitch
Nov 10 at 17:00
you didn't give the db network a name declaration for specific name?name: db?
– uberrebu
Nov 10 at 17:02
so yes i have this now and am still getting issues...i just did for wpapp1 and still getting the url loadbalanced via traefik, so not sure where the loadbalancing is happening but its happeing still even with separating db network
– uberrebu
Nov 10 at 17:03
|
show 2 more comments
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Put your database on a different network. Otherwise WordPress will RR load balance to the two mysql instances in the same docker network (that's the expected behavior when you have two containers with the same alias on the same network). You can do that with the default network:
version: '3.5'
services:
mysql:
image: mysql:5.7
volumes:
- mysql:/var/lib/mysql
restart: unless-stopped
networks:
- db
environment:
MYSQL_ROOT_PASSWORD: wpapp
MYSQL_DATABASE: wpapp
MYSQL_USER: wpapp
MYSQL_PASSWORD: wpapp
wordpress:
depends_on:
- mysql
image: wordpress:latest
volumes:
- wordpress:/var/www/html
restart: unless-stopped
networks:
- traefik
- db
labels:
- "traefik.frontend.rule=Host:wpapp1.example.com"
- "traefik.port=80"
- "traefik.docker.network=traefik_network"
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_USER: wpapp
WORDPRESS_DB_PASSWORD: wpapp
volumes:
mysql:
wordpress:
networks:
db:
traefik:
external:
name: traefik_network
can i use custom network name rather than usedefault? can i use likedb_networkor something custom?
– uberrebu
Nov 10 at 16:57
making it unique is not a problem...i think i just did that and still getting issues
– uberrebu
Nov 10 at 16:59
Updated with a db network name
– BMitch
Nov 10 at 17:00
you didn't give the db network a name declaration for specific name?name: db?
– uberrebu
Nov 10 at 17:02
so yes i have this now and am still getting issues...i just did for wpapp1 and still getting the url loadbalanced via traefik, so not sure where the loadbalancing is happening but its happeing still even with separating db network
– uberrebu
Nov 10 at 17:03
|
show 2 more comments
up vote
1
down vote
accepted
Put your database on a different network. Otherwise WordPress will RR load balance to the two mysql instances in the same docker network (that's the expected behavior when you have two containers with the same alias on the same network). You can do that with the default network:
version: '3.5'
services:
mysql:
image: mysql:5.7
volumes:
- mysql:/var/lib/mysql
restart: unless-stopped
networks:
- db
environment:
MYSQL_ROOT_PASSWORD: wpapp
MYSQL_DATABASE: wpapp
MYSQL_USER: wpapp
MYSQL_PASSWORD: wpapp
wordpress:
depends_on:
- mysql
image: wordpress:latest
volumes:
- wordpress:/var/www/html
restart: unless-stopped
networks:
- traefik
- db
labels:
- "traefik.frontend.rule=Host:wpapp1.example.com"
- "traefik.port=80"
- "traefik.docker.network=traefik_network"
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_USER: wpapp
WORDPRESS_DB_PASSWORD: wpapp
volumes:
mysql:
wordpress:
networks:
db:
traefik:
external:
name: traefik_network
can i use custom network name rather than usedefault? can i use likedb_networkor something custom?
– uberrebu
Nov 10 at 16:57
making it unique is not a problem...i think i just did that and still getting issues
– uberrebu
Nov 10 at 16:59
Updated with a db network name
– BMitch
Nov 10 at 17:00
you didn't give the db network a name declaration for specific name?name: db?
– uberrebu
Nov 10 at 17:02
so yes i have this now and am still getting issues...i just did for wpapp1 and still getting the url loadbalanced via traefik, so not sure where the loadbalancing is happening but its happeing still even with separating db network
– uberrebu
Nov 10 at 17:03
|
show 2 more comments
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Put your database on a different network. Otherwise WordPress will RR load balance to the two mysql instances in the same docker network (that's the expected behavior when you have two containers with the same alias on the same network). You can do that with the default network:
version: '3.5'
services:
mysql:
image: mysql:5.7
volumes:
- mysql:/var/lib/mysql
restart: unless-stopped
networks:
- db
environment:
MYSQL_ROOT_PASSWORD: wpapp
MYSQL_DATABASE: wpapp
MYSQL_USER: wpapp
MYSQL_PASSWORD: wpapp
wordpress:
depends_on:
- mysql
image: wordpress:latest
volumes:
- wordpress:/var/www/html
restart: unless-stopped
networks:
- traefik
- db
labels:
- "traefik.frontend.rule=Host:wpapp1.example.com"
- "traefik.port=80"
- "traefik.docker.network=traefik_network"
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_USER: wpapp
WORDPRESS_DB_PASSWORD: wpapp
volumes:
mysql:
wordpress:
networks:
db:
traefik:
external:
name: traefik_network
Put your database on a different network. Otherwise WordPress will RR load balance to the two mysql instances in the same docker network (that's the expected behavior when you have two containers with the same alias on the same network). You can do that with the default network:
version: '3.5'
services:
mysql:
image: mysql:5.7
volumes:
- mysql:/var/lib/mysql
restart: unless-stopped
networks:
- db
environment:
MYSQL_ROOT_PASSWORD: wpapp
MYSQL_DATABASE: wpapp
MYSQL_USER: wpapp
MYSQL_PASSWORD: wpapp
wordpress:
depends_on:
- mysql
image: wordpress:latest
volumes:
- wordpress:/var/www/html
restart: unless-stopped
networks:
- traefik
- db
labels:
- "traefik.frontend.rule=Host:wpapp1.example.com"
- "traefik.port=80"
- "traefik.docker.network=traefik_network"
environment:
WORDPRESS_DB_HOST: mysql:3306
WORDPRESS_DB_USER: wpapp
WORDPRESS_DB_PASSWORD: wpapp
volumes:
mysql:
wordpress:
networks:
db:
traefik:
external:
name: traefik_network
edited Nov 10 at 17:00
answered Nov 10 at 16:55
BMitch
54.1k9108125
54.1k9108125
can i use custom network name rather than usedefault? can i use likedb_networkor something custom?
– uberrebu
Nov 10 at 16:57
making it unique is not a problem...i think i just did that and still getting issues
– uberrebu
Nov 10 at 16:59
Updated with a db network name
– BMitch
Nov 10 at 17:00
you didn't give the db network a name declaration for specific name?name: db?
– uberrebu
Nov 10 at 17:02
so yes i have this now and am still getting issues...i just did for wpapp1 and still getting the url loadbalanced via traefik, so not sure where the loadbalancing is happening but its happeing still even with separating db network
– uberrebu
Nov 10 at 17:03
|
show 2 more comments
can i use custom network name rather than usedefault? can i use likedb_networkor something custom?
– uberrebu
Nov 10 at 16:57
making it unique is not a problem...i think i just did that and still getting issues
– uberrebu
Nov 10 at 16:59
Updated with a db network name
– BMitch
Nov 10 at 17:00
you didn't give the db network a name declaration for specific name?name: db?
– uberrebu
Nov 10 at 17:02
so yes i have this now and am still getting issues...i just did for wpapp1 and still getting the url loadbalanced via traefik, so not sure where the loadbalancing is happening but its happeing still even with separating db network
– uberrebu
Nov 10 at 17:03
can i use custom network name rather than use
default? can i use like db_network or something custom?– uberrebu
Nov 10 at 16:57
can i use custom network name rather than use
default? can i use like db_network or something custom?– uberrebu
Nov 10 at 16:57
making it unique is not a problem...i think i just did that and still getting issues
– uberrebu
Nov 10 at 16:59
making it unique is not a problem...i think i just did that and still getting issues
– uberrebu
Nov 10 at 16:59
Updated with a db network name
– BMitch
Nov 10 at 17:00
Updated with a db network name
– BMitch
Nov 10 at 17:00
you didn't give the db network a name declaration for specific name?
name: db?– uberrebu
Nov 10 at 17:02
you didn't give the db network a name declaration for specific name?
name: db?– uberrebu
Nov 10 at 17:02
so yes i have this now and am still getting issues...i just did for wpapp1 and still getting the url loadbalanced via traefik, so not sure where the loadbalancing is happening but its happeing still even with separating db network
– uberrebu
Nov 10 at 17:03
so yes i have this now and am still getting issues...i just did for wpapp1 and still getting the url loadbalanced via traefik, so not sure where the loadbalancing is happening but its happeing still even with separating db network
– uberrebu
Nov 10 at 17:03
|
show 2 more comments
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53240720%2ftraefik-not-respecting-frontend-rule%23new-answer', 'question_page');
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Are you sure it's traefik load balancing and not WordPress load balancing to the duplicate mysql instances in the same traefik network?
– BMitch
Nov 10 at 16:38
well not sure..what do i do to not make that happen? lets assume its wordpress doing that..because i just checked logs and i see that even database are getting loadbalanced too..i mean i have docker-compose so why isn't there separation between the apps? am not like exposing ports on host so not sure why docker is behaving like this
– uberrebu
Nov 10 at 16:43
Put mysql on a different network, easiest is to not put it on a network at all and let compose make the default network. Then put WordPress on both the traefik and default networks (the default network name is "default").
– BMitch
Nov 10 at 16:47
i have tried using different networks for the apps..but then traefik does not work when i have apps in another network..so anyone that can help with best way to segment these apps behind traefik..will appreciate it
– uberrebu
Nov 10 at 16:47
i will like to give my own network names rather than use default network..and when i tried doing that traefik did not pick up anything and was getting gateway timeouts..so how can i specify different networks for mysql and then have wordpress on traefik network and the custom network for the different apps?
– uberrebu
Nov 10 at 16:49