magento / magento-cloud-docker

All Submissions you make to Magento Inc. (“Magento") through GitHub are subject to the following terms and conditions: (1) You grant Magento a perpetual, worldwide, non-exclusive, no charge, royalty free, irrevocable license under your applicable copyrights and patents to reproduce, prepare derivative works of, display, publically perform, sublicense and distribute any feedback, ideas, code, or other information (“Submission") you submit through GitHub. (2) Your Submission is an original work of authorship and you are the owner or are legally entitled to grant the license stated above. (3) You agree to the Contributor License Agreement found here: https://github.com/magento/magento2/blob/master/CONTRIBUTOR_LICENSE_AGREEMENT.html
Open Software License 3.0
253 stars 191 forks source link

504 Gateway Time-out #307

Open sivamind opened 3 years ago

sivamind commented 3 years ago

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:

YPyltiai commented 3 years ago

@oshmyheliuk , @NadiyaS , please review.

oshmyheliuk commented 3 years ago

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

sorinsugar commented 3 years ago

@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

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..

birdman002 commented 3 years ago

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

lwmatysik commented 3 years ago

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
tuan-dinh0510 commented 3 years ago

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:
shiftedreality commented 3 years ago

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

qaniel commented 3 years ago

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 :)

yvikt commented 1 year ago

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