magento-cloud-docker icon indicating copy to clipboard operation
magento-cloud-docker copied to clipboard

504 Gateway Time-out

Open sivamind opened this issue 4 years ago • 9 comments

below is my yaml file and host system is windows 10 version: '2.1' services: db: hostname: db.magento2.docker image: 'mariadb:10.2' environment: - MYSQL_ROOT_PASSWORD=magento2 - MYSQL_DATABASE=magento2 - MYSQL_USER=magento2 - MYSQL_PASSWORD=magento2 ports: - '3306' volumes: - '.:/app:delegated' - 'kp_magento_marketplace-magento-db:/var/lib/mysql' healthcheck: test: 'mysqladmin ping -h localhost -pmagento2' interval: 30s timeout: 30s retries: 3 networks: magento: aliases: - db.magento2.docker redis: hostname: redis.magento2.docker image: 'redis:5.0' volumes: - '.:/app:delegated' ports: - 6379 healthcheck: test: 'redis-cli ping || exit 1' interval: 30s timeout: 30s retries: 3 networks: magento: aliases: - redis.magento2.docker elasticsearch: hostname: elasticsearch.magento2.docker image: 'magento/magento-cloud-docker-elasticsearch:6.5-1.2.0' networks: magento: aliases: - elasticsearch.magento2.docker fpm: hostname: fpm.magento2.docker image: 'magento/magento-cloud-docker-php:7.3-fpm-1.2.0' extends: generic volumes: - '.:/app:delegated' networks: magento: aliases: - fpm.magento2.docker depends_on: db: condition: service_healthy web: hostname: web.magento2.docker image: 'magento/magento-cloud-docker-nginx:1.19-1.2.0' extends: generic volumes: - '.:/app:delegated' environment: - WITH_XDEBUG=0 networks: magento: aliases: - web.magento2.docker depends_on: fpm: condition: service_started varnish: hostname: varnish.magento2.docker image: 'magento/magento-cloud-docker-varnish:6.2-1.2.0' networks: magento: aliases: - varnish.magento2.docker depends_on: web: condition: service_started tls: hostname: tls.magento2.docker image: 'magento/magento-cloud-docker-nginx:1.19-1.2.0' extends: generic networks: magento: aliases: - magento2.docker environment: UPSTREAM_HOST: varnish ports: - '80:80' - '443:443' depends_on: varnish: condition: service_started generic: hostname: generic.magento2.docker image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' env_file: ./.docker/config.env environment: - MAGENTO_RUN_MODE=developer - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip redis xsl sodium' build: hostname: build.magento2.docker image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' extends: generic volumes: - '.:/app:delegated' networks: magento-build: aliases: - build.magento2.docker depends_on: db: condition: service_healthy redis: condition: service_healthy elasticsearch: condition: service_healthy deploy: hostname: deploy.magento2.docker image: 'magento/magento-cloud-docker-php:7.3-cli-1.2.0' extends: generic volumes: - '.:/app:delegated' networks: magento: aliases: - deploy.magento2.docker depends_on: db: condition: service_healthy redis: condition: service_healthy elasticsearch: condition: service_healthy mailhog: hostname: mailhog.magento2.docker image: 'mailhog/mailhog:latest' ports: - '1025:1025' - '8025:8025' networks: magento: aliases: - mailhog.magento2.docker volumes: kp_magento_marketplace-magento-db: { } networks: magento: driver: bridge magento-build: driver: bridge

sivamind avatar Feb 04 '21 02:02 sivamind

@oshmyheliuk , @NadiyaS , please review.

YPyltiai avatar Feb 11 '21 15:02 YPyltiai

@sivamind Hi, Do you still face this error? Could you please paste the content of your docker-compose.yaml with code markdown format: ``` code ```

oshmyheliuk avatar Feb 11 '21 15:02 oshmyheliuk

@oshmyheliuk We've received this 504 error for a couple of times as well. One thing that I've seen is the fact the the reverse proxy settings in tls have no timeout set, thus nginx uses the default value. Maybe it's worth tweaking this.

Also, for some reason the timeouts on different containers are so "different" in values

  • varnish has 300 seconds
  • tls proxy has default (I think it's 60 seconds)
  • web has 600
  • fastcgi has 600

I think we should pass the same value to all parties involved, or decrease it until we reach php, that way if php time out is reached, we can get a response up till tls..

sorinsugar avatar Feb 16 '21 09:02 sorinsugar

This is what happened to me. Verify all your caches are turned on.

birdman002 avatar Mar 03 '21 16:03 birdman002

I ran into this also. After deploying (2.3.5-p2) the caches were setup like this:

Current status:
                        config: 0
                        layout: 1
                    block_html: 1
                   collections: 0
                    reflection: 0
                        db_ddl: 0
               compiled_config: 0
            config_integration: 0
        config_integration_api: 0
                     full_page: 1
                   target_rule: 0
             config_webservice: 0
                     translate: 0
                        vertex: 0

lwmatysik avatar Apr 11 '21 17:04 lwmatysik

I have the same issue also, 504 quite often

version: '2.1'
services:
    mysql_magento:
        image: 'mariadb:10.2'
        environment:
            - MYSQL_ROOT_PASSWORD=magento2
            - MYSQL_DATABASE=magento2
            - MYSQL_USER=magento2
            - MYSQL_PASSWORD=magento2
        volumes:
            - './.docker/mysql/:/var/lib/mysql'
        healthcheck:
            test: 'mysqladmin ping -h localhost'
            interval: 30s
            timeout: 30s
            retries: 3
        networks:
            magento:
                aliases:
                    - mysql_magento

    elasticsearch_magento:
        image: markoshust/magento-elasticsearch:7.6.2-2
        environment:
            - "discovery.type=single-node"
        networks:
            magento:
                aliases:
                    - elasticsearch_magento

    fpm:
        hostname: fpm.magento2.docker
        image: 'magento/magento-cloud-docker-php:7.3-fpm-1.1'
        extends: generic
        volumes:
            - '.:/app:delegated'
            - './.docker/mnt:/mnt:rw,delegated'
        environment:
            - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip xsl sodium xdebug'
        networks:
            magento:
                aliases:
                    - fpm_magento
        depends_on:
            mysql_magento:
                condition: service_started

    web:
        hostname: web.magento2.docker
        image: 'magento/magento-cloud-docker-nginx:1.19-1.2.1'
        extends: generic
        volumes:
            - '.:/app:delegated'
        environment:
            - WITH_XDEBUG=1
            - NGINX_WORKER_PROCESSES=4
            - NGINX_WORKER_CONNECTIONS=1024
        networks:
            magento:
                aliases:
                    - nginx_magento
        depends_on:
            fpm:
                condition: service_started

    varnish:
        hostname: varnish.magento2.docker
        image: 'magento/magento-cloud-docker-varnish:6.2-1.2.1'
        networks:
            magento:
                aliases:
                    - varnish_magento
        depends_on:
            web:
                condition: service_started

    tls:
        hostname: tls.magento2.docker
        image: 'magento/magento-cloud-docker-nginx:1.19-1.2.1'
        extends: generic
        volumes:
            - './.docker/log/:/var/log/nginx/:delegated'
        networks:
            magento:
                aliases:
                    - tls_magento
        environment:
            - NGINX_WORKER_PROCESSES=4
            - NGINX_WORKER_CONNECTIONS=1024
            - UPSTREAM_HOST=varnish
            - UPSTREAM_PORT=80
        depends_on:
            varnish:
                condition: service_started

    generic:
        hostname: generic.magento2.docker
        image: 'magento/magento-cloud-docker-php:7.3-cli-1.1'
        volumes:
            - './.composer:/app/.composer:rw,delegated'
        env_file: ./.docker/config.env
        environment:
            - MAGENTO_RUN_MODE=developer
            - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip redis xsl sodium'

    redis_magento:
        image: redis:5.0-alpine
        networks:
            magento:
                aliases:
                    - redis_magento

    mailhog:
        hostname: mailhog.magento2.docker
        image: 'mailhog/mailhog:latest'
        networks:
            magento:
                aliases:
                    - mailhog_magento

    phpmyadmin:
        image: phpmyadmin
        environment:
            - PMA_HOST=mysql_magento
            - PMA_PORT=3306
        volumes:
            - './.docker/phpmyadmin/sessions:/sessions'
        networks:
            magento:
                aliases:
                    - phpmyadmin_magento

    build:
        image: 'magento/magento-cloud-docker-php:7.3-cli-1.1'
        extends: generic
        volumes:
            - '.:/app:rw,delegated'
            - './vendor:/app/vendor:rw,delegated'
            - './generated:/app/generated:rw,delegated'
            - '~/.composer/cache:/root/.composer/cache:rw,delegated'
            - './.composer/auth.json:/root/.composer/auth.json:rw,delegated'
        networks:
            magento:
                aliases:
                    - magecli_magento
        depends_on:
            mysql_magento:
                condition: service_started
            redis_magento:
                condition: service_started
            elasticsearch_magento:
                condition: service_started

    fpm_xdebug:
        hostname: fpm_xdebug.magento2.docker
        image: 'magento/magento-cloud-docker-php:7.3-fpm-1.1'
        extends: generic
        volumes:
            - '.:/app:ro,delegated'
            - './vendor:/app/vendor:ro,delegated'
            - './generated:/app/generated:rw,delegated'
            - './var:/app/var:rw,delegated'
            - './app/etc:/app/app/etc:rw,delegated'
            - './pub/media:/app/pub/media:rw,delegated'
            - './pub/static:/app/pub/static:rw,delegated'
            - './.docker/mnt:/mnt:rw,delegated'
        environment:
            - 'PHP_EXTENSIONS=bcmath bz2 calendar exif gd gettext intl mysqli pcntl pdo_mysql soap sockets sysvmsg sysvsem sysvshm opcache zip xsl sodium xdebug'
        networks:
            magento:
                aliases:
                    - fpm_xdebug.magento2.docker
        depends_on:
            mysql_magento:
                condition: service_started

networks:
    magento:
        driver: bridge

volumes:
    sockdata:

tuan-dinh0510 avatar Jun 10 '21 10:06 tuan-dinh0510

Thank you for reporting his. We have created an internal ticket MCLOUD-7992 to investigate

shiftedreality avatar Jun 10 '21 13:06 shiftedreality

AFAIK this happens cuz docker + developer mode + local environment + 0 caches. So, there are only 2 workarounds for this

  1. Update the Nginx timeout
  2. Turn all the caches and only clear the ones that are related to your current work (I Recommend this)

With point 2 you will still get some 504 (during page builder related requests most of the time) occasionally but nothing that a fast refresh cant fix :)

qaniel avatar Aug 06 '21 16:08 qaniel

In my case the issue was related to implicitly default 60 second value of proxy_read_timeout in /etc/nginx/conf.d/default.conf incide TLS container. Solved this by adding proxy_read_timeout 600; in server listen 80 section under location / where the rest of proxy_pass instructions are set for varnish.

docker exec -ti $(docker ps --format "{{.Names}}" | grep tls) bash apt install vim vim /etc/nginx/conf.d/default.conf

yvikt avatar Nov 01 '22 07:11 yvikt