I created a subdomain in my hosting company.
I put the label in composer pointing to this domain
("well.rcasistemas.delivery")
And everything seemed to work fine.
But whenever I refreshed the page in the browser, the server directed access to another container, and it seemed to be random.
That makes sense?
Hello @nathanarca,
Are you using Traefik Mesh for this? Or did you mean to open this issue on the Traefik Proxy category?
Sorry, I changed the category.
Hello @nathanarca,
In that case, when you say that your request is redirected to another container, do you have multiple containers that are serving the same application?
Can you provide your Traefik configuration for us?
I have several containers serving the same application, but with their separate volumes.
What directs the client to his container is the subdomain, which in this case started with "well"
The traefik configuration below.
version: "3"
services:
reverse-proxy:
image: traefik:v2.0
command:
- "--api.insecure=true"
- "--providers.docker=true"
- "--providers.docker.exposedbydefault=false"
- "--entrypoints.web.address=:80"
- "--entrypoints.websecure.address=:443"
- "--entrypoints.other.address=:9090"
- "--certificatesresolvers.myhttpchallenge.acme.httpchallenge=true"
- "--certificatesresolvers.myhttpchallenge.acme.httpchallenge.entrypoint=web"
- "--certificatesresolvers.myhttpchallenge.acme.caserver=https://acme-v02.api.letsencrypt.org/directory"
- "--certificatesresolvers.myhttpchallenge.acme.email=nathanarrudacamara@gmail.com"
- "--certificatesresolvers.myhttpchallenge.acme.storage=/letsencrypt/acme.json"
ports:
- "${SERVER_IP}:80:80"
- "${SERVER_IP}:443:443"
- "${SERVER_IP}:9090:9090"
- "${SERVER_IP}:8080:8080"
volumes:
- "./letsencrypt:/letsencrypt"
- "/var/run/docker.sock:/var/run/docker.sock:ro"
networks:
- traefik-public
restart: always
networks:
traefik-public:
Little pattern.
Hello @nathanarca,
Since you are using the docker provider, can you provide us the labels on the containers that are not routing properly?
Of course.
version: "3.7"
services:
#PHP Service
app:
build:
context: .
dockerfile: Dockerfile
image: cloudsigma.com/php
container_name: well_app
restart: unless-stopped
tty: true
environment:
SERVICE_NAME: app
SERVICE_TAGS: dev
working_dir: /var/www/html/
volumes:
- ./app/:/var/www/html/
- ./php/laravel.ini:/usr/local/etc/php/conf.d/laravel.ini
networks:
- app-network
- traefik-public
#Nginx Service
webserver:
image: nginx:alpine
container_name: well_webserver
restart: unless-stopped
tty: true
ports:
- "80"
- "443"
volumes:
- ./app/:/var/www/html/
- ./nginx/conf.d/:/etc/nginx/conf.d/
networks:
- app-network
- traefik-public
labels:
- "traefik.enable=true"
- traefik.http.routers.well_route.rule=Host(`well.rcasistemas.delivery`)
- traefik.http.routers.well_route.entrypoints=web
- traefik.http.middlewares.well_route.redirectscheme.scheme=https
- traefik.http.routers.well_route.middlewares=well_route
- traefik.http.routers.well_route-secured.rule=Host(`well.rcasistemas.delivery`)
- traefik.http.routers.well_route-secured.entrypoints=websecure
- traefik.http.routers.well_route-secured.tls=true
- traefik.http.routers.well_route-secured.tls.certresolver=myhttpchallenge
- traefik.docker.network=traefik-public
#MySQL Service
db:
image: mariadb
restart: always
container_name: well_db
ports:
- "3306"
environment:
- MYSQL_ROOT_HOST=%
- MYSQL_ROOT_PASSWORD=${MYSQL_ROOT_PASSWORD}
- MYSQL_USER=laravel
- MYSQL_PASSWORD=laravel
- MYSQL_DATABASE=delivery
volumes:
- ./database/:/var/lib/mysql/
- ./mysql/my.cnf:/etc/mysql/my.cnf
networks:
- app-network
#Redis Service
redis:
image: "redis:alpine"
restart: always
command: "redis-server --appendonly yes"
container_name: well_redis
volumes:
- ./redis:/data
environment:
- REDIS_REPLICATION_MODE=master
networks:
- app-network
#Docker Networks
networks:
app-network:
driver: bridge
traefik-public:
external:
name: traefik-public
Hello @nathanarca,
That configuration looks ok from what I can tell. You say that the requests are being routed to another container? what are the labels on the container that are receiving the requests that you don't want?
The configuration of the other containers is similar.
The only change I make is to replace that word "well" with anything else.
What I found strange is that with any other word it works perfectly.
But when I create and start the container with this configuration that I went through, and I try to access "well.rcassitemas.delivery" the server is picking up another container at random.