Поднял Docker, который проксирует запросы через Traefik. Между сервисами запросы проходят мгновенно, но если посылаю на внешние сервисы, типа
https://jsonplaceholder.typicode.com/todos/1, то ожидаю ответа в течении 5 секунд. Если выполняют команду в bash на сервере curl
https://jsonplaceholder.typicode.com/todos/1, то также все быстро, а если в nginx контейнере, то появляется ожидание. Подскажите пожалуйста как настроить? Уже 2 дня убил на решение этой проблемы...
version: '3.3'
services:
traefik:
image: traefik:v3.0
ports:
- 80:80
- 443:443
- 8080:8080
networks:
- proxy
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- ./letsencrypt:/letsencrypt
#- /var/log:/var/log
command:
- --api=true
- --api.dashboard=true
- --accesslog=true
- --providers.docker.network=proxy
- --providers.docker.exposedByDefault=false
- --entrypoints.web.address=:80
- --entrypoints.web.http.redirections.entrypoint.to=websecure
- --entryPoints.web.http.redirections.entrypoint.scheme=https
- --entrypoints.websecure.address=:443
- --entrypoints.websecure.asDefault=true
- --entrypoints.websecure.http.tls.certresolver=myresolver
- --certificatesresolvers.myresolver.acme.email=****
- --certificatesresolvers.myresolver.acme.httpchallenge.entrypoint=web
- --certificatesresolvers.myresolver.acme.storage=/letsencrypt/acme.json
labels:
- traefik.enable=true
- "traefik.http.routers.traefik.rule=Host(`traefik.****`)" # domain for dashboard
- "traefik.http.routers.traefik.entrypoints=websecure"
- "traefik.http.routers.traefik.tls.certresolver=letsencrypt"
- "traefik.http.routers.traefik.service=api@internal" # points to dashboard
- "traefik.http.routers.traefik.middlewares=auth" # enable password auth
- "traefik.http.middlewares.auth.basicauth.users=admin:$$apr1$$Dqo7TC2B$$23bAWltXXzx01XUbq2BU50"
nginx_****
image: nginx:stable-alpine
container_name: nginx_****
ports:
- "8000:80"
volumes:
- ./src/****:/var/www/html:delegated
- ./nginx/****.conf:/etc/nginx/conf.d/default.conf
labels:
- traefik.enable=true
- providers.docker.network=proxy
- traefik.http.services.****loadbalancer.server.port=80
- "traefik.http.routers.****rule=Host(`****`) && PathPrefix(`/`)"
networks:
- proxy
depends_on:
- php_****
- mysql
nginx_api:
image: nginx:stable-alpine
container_name: nginx_api
volumes:
- ./src/****:/var/www/html:delegated
- ./nginx/****.conf:/etc/nginx/conf.d/default.conf
ports:
- "8100:80"
labels:
- traefik.enable=true
- providers.docker.network=proxy
- traefik.http.services.nginx_api.loadbalancer.server.port=80
- "traefik.http.routers.nginx_api.rule=Host(`****`) && PathPrefix(`/`)"
networks:
- proxy
depends_on:
- php
- mysql
nginx_app:
image: nginx:stable-alpine
container_name: nginx_app
ports:
- "8200:80"
volumes:
- ./src/****:/var/www/html:delegated
- ./nginx/****.conf:/etc/nginx/conf.d/default.conf
labels:
- traefik.enable=true
- providers.docker.network=proxy
- traefik.http.services.nginx_app.loadbalancer.server.port=80
- "traefik.http.routers.nginx_app.rule=Host(`****`) && PathPrefix(`/`)"
networks:
- proxy
nginx_****:
image: nginx:stable-alpine
container_name: nginx_****
ports:
- "8300:80"
volumes:
- ./src/****:/var/www/html:delegated
- ./nginx/****conf:/etc/nginx/conf.d/default.conf
labels:
- traefik.enable=true
- providers.docker.network=proxy
- traefik.http.services.nginx_****.loadbalancer.server.port=80
- "traefik.http.routers.nginx_****.rule=Host(`****`) && PathPrefix(`/`)"
networks:
- proxy
php:
build:
context: ./php/
dockerfile: DockerFile_api
container_name: php_api
volumes:
- ./src/****_api:/var/www/html
ports:
- "9000:9000"
networks:
- proxy
links:
- mysql
depends_on:
- mysql
php_****:
build:
context: ./php/
dockerfile: DockerFile_****
container_name: php_****
volumes:
- ./src/****:/var/www/html
ports:
- "9100:9000"
networks:
- proxy
links:
- mysql
depends_on:
- mysql
mysql:
image: mysql:5.7.22
container_name: mysql
restart: unless-stopped
tty: true
ports:
- "3306:3306"
volumes:
- ./.database:/var/lib/mysql
environment:
MYSQL_DATABASE: ****
MYSQL_USER: root
MYSQL_PASSWORD: ****
MYSQL_ROOT_PASSWORD: ****
SERVICE_TAGS: dev
SERVICE_NAME: mysql
networks:
- proxy
labels:
- traefik.enable=true
- providers.docker.network=proxy
whoami:
image: traefik/whoami:v1.8
networks:
- proxy
labels:
- traefik.enable=true
- providers.docker.network=proxy
- traefik.http.middlewares.mywwwredirect.redirectregex.regex=^https://www\.(.*)
- traefik.http.middlewares.mywwwredirect.redirectregex.replacement=https://$${1}
- traefik.http.routers.mywhoami.middlewares=mywwwredirect
networks:
proxy:
external: true