flask-on-docker
flask-on-docker copied to clipboard
Gateway Timeout
Hey there,
I followed the tutorial and everything seemed to work out quite well except for the part that I cannot access the site and it's simply giving me a Gateway Timeout when I try to access the configured subdomain.
Please note that I do not have local access to the mydomain.com server so testing via localhost:5001 is not possible for me. However, this kind of subdomain-to-service configuration via labels is definitely working for several other containers.
docker-compose.prod.yaml
version: '3.3'
services:
nginx-csc:
build: ./nginx
container_name: prod_nginx
volumes:
- static_volume:/home/app/web/project/static
labels:
- "traefik.enable=true"
- "traefik.http.routers.nginx-csc.entrypoints=http"
- "traefik.http.routers.nginx-csc.rule=Host(`test.mydomain.com`)"
- "traefik.http.routers.nginx-csc-secure.entrypoints=https"
- "traefik.http.routers.nginx-csc-secure.rule=Host(`test.mydomain.com`)"
- "traefik.http.routers.nginx-csc-secure.tls=true"
- "traefik.http.routers.nginx-csc-secure.tls.certresolver=http"
- "traefik.http.routers.nginx-csc-secure.service=nginx-csc"
- "traefik.http.routers.nginx-csc-secure.middlewares=secHeaders@file,httpsRedirect@file"
- "traefik.http.services.nginx-csc.loadbalancer.server.port=80"
depends_on:
- web
web:
build:
context: ./web
dockerfile: Dockerfile.prod
container_name: prod_web
command: gunicorn --bind 0.0.0.0:5000 manage:app
env_file:
- ./.env.prod
depends_on:
- db
db:
image: postgres:13
container_name: prod_db
volumes:
- postgres_data_prod:/var/lib/postgresql/data/
env_file:
- ./.env.prod.db
volumes:
postgres_data_prod:
static_volume:
nginx.conf
upstream hello_flask {
server web:5000;
}
server {
listen 80;
location / {
proxy_pass http://hello_flask;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Host $host;
proxy_redirect off;
}
location /static/ {
alias /home/app/web/project/static/;
}
}
I start the stack via docker-compose -f docker-compose.prod.yaml up -d --build
.
According to the log files, everything is running without problem:
web service
Waiting for postgres...
PostgreSQL started
[2023-08-04 16:02:55 +0000] [1] [INFO] Starting gunicorn 20.1.0
[2023-08-04 16:02:55 +0000] [1] [INFO] Listening at: http://0.0.0.0:5000 (1)
[2023-08-04 16:02:55 +0000] [1] [INFO] Using worker: sync
[2023-08-04 16:02:55 +0000] [49] [INFO] Booting worker with pid: 49
db service
2023-08-04 16:02:51.294 UTC [1] LOG: starting PostgreSQL 13.11 (Debian 13.11-1.pgdg120+1) on x86_64-pc-linux-gnu, compiled by gcc (Debian 12.2.0-14) 12.2.0, 64-bit
2023-08-04 16:02:51.300 UTC [1] LOG: listening on IPv4 address "0.0.0.0", port 5432
2023-08-04 16:02:51.302 UTC [1] LOG: listening on IPv6 address "::", port 5432
2023-08-04 16:02:51.305 UTC [1] LOG: listening on Unix socket "/var/run/postgresql/.s.PGSQL.5432"
2023-08-04 16:02:51.319 UTC [61] LOG: database system was shut down at 2023-08-04 16:02:51 UTC
2023-08-04 16:02:51.882 UTC [1] LOG: database system is ready to accept connections
nginx service
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration
/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d/
/docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh
10-listen-on-ipv6-by-default.sh: info: /etc/nginx/conf.d/default.conf is not a file or does not exist
/docker-entrypoint.sh: Sourcing /docker-entrypoint.d/15-local-resolvers.envsh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh
/docker-entrypoint.sh: Launching /docker-entrypoint.d/30-tune-worker-processes.sh
/docker-entrypoint.sh: Configuration complete; ready for start up
2023/08/04 16:02:53 [notice] 1#1: using the "epoll" event method
2023/08/04 16:02:53 [notice] 1#1: nginx/1.25.1
2023/08/04 16:02:53 [notice] 1#1: built by gcc 12.2.0 (Debian 12.2.0-14)
2023/08/04 16:02:53 [notice] 1#1: OS: Linux 5.4.0-155-generic
2023/08/04 16:02:53 [notice] 1#1: getrlimit(RLIMIT_NOFILE): 1048576:1048576
2023/08/04 16:02:53 [notice] 1#1: start worker processes
2023/08/04 16:02:53 [notice] 1#1: start worker process 19
I don't even get a HTTP status code, just a Gateway Timeout. Does anybody have an idea why?