docker4drupal icon indicating copy to clipboard operation
docker4drupal copied to clipboard

NodeJS application is returning 502 Bad Gateway

Open rafatwork opened this issue 7 years ago • 14 comments

I'm trying to get the ContentaCMS (http://www.contentacms.org/) distribution together with the Vue.js+Nuxt example (https://github.com/contentacms/contenta_vue_nuxt) to work on Docker4Drupal.

The regular Drupal installation is installed through Composer, eg.

composer create-project contentacms/contenta-jsonapi-project <DESTINATION> --stability dev --no-interaction

In the root of the project, I created a folder "front" which contains the Nuxt (NodeJS) application. My codebase folder structure looks as following:

drwxr-xr-x 1 Raf 197609      0 Apr  3 19:02 ./
drwxr-xr-x 1 Raf 197609      0 Apr  3 13:57 ../
-rw-r--r-- 1 Raf 197609   2419 Apr  3 14:03 .env
drwxr-xr-x 1 Raf 197609      0 Apr  3 14:12 .idea/
drwxr-xr-x 1 Raf 197609      0 Apr  3 14:01 bin/
-rw-r--r-- 1 Raf 197609   2015 Apr  3 14:07 composer.json
-rw-r--r-- 1 Raf 197609 210150 Apr  3 14:08 composer.lock
-rw-r--r-- 1 Raf 197609   7387 Apr  3 19:28 docker-compose.yml
drwxr-xr-x 1 Raf 197609      0 Apr  3 19:17 front/
drwxr-xr-x 1 Raf 197609      0 Apr  3 19:02 keys/
drwxr-xr-x 1 Raf 197609      0 Apr  3 13:57 patches/
-rw-r--r-- 1 Raf 197609   3602 Apr  3 13:57 README.md
drwxr-xr-x 1 Raf 197609      0 Apr  3 13:57 scripts/
drwxr-xr-x 1 Raf 197609      0 Apr  3 14:08 vendor/
drwxr-xr-x 1 Raf 197609      0 Apr  3 19:18 web/

The Drupal installation works fine (http://contentacms.docker.localhost:8000). The NodeJS application however returns a "Bad Gateway" response (http://front.contentacms.docker.localhost:8000).

Any help would be appreciated.

Codebase

Mounted codebase

Host OS

Windows 10

Docker info output

Containers: 95
 Running: 7
 Paused: 0
 Stopped: 88
Images: 64
Server Version: 17.12.0-ce
Storage Driver: overlay2
 Backing Filesystem: extfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host ipvlan macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: 89623f28b87a6004d4b785663257362d1658a729
runc version: b2567b37d7b75eb4cf325b77297b140ea686ce8f
init version: 949e6fa
Security Options:
 seccomp
  Profile: default
Kernel Version: 4.9.60-linuxkit-aufs
Operating System: Docker for Windows
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 7.769GiB
Name: linuxkit-00155df4682a
ID: JLXY:NAMP:3U2J:GKMB:IP2K:5ZB5:5H6Y:KYF7:ATC2:XMKE:S5HI:B63R
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): true
 File Descriptors: 76
 Goroutines: 82
 System Time: 2018-04-03T17:32:11.0455573Z
 EventsListeners: 2
Registry: https://index.docker.io/v1/
Labels:
Experimental: true
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false

Docker compose file

version: "2"

services:
  mariadb:
    image: wodby/mariadb:$MARIADB_TAG
    container_name: "${PROJECT_NAME}_mariadb"
    stop_grace_period: 30s
    environment:
      MYSQL_ROOT_PASSWORD: $DB_ROOT_PASSWORD
      MYSQL_DATABASE: $DB_NAME
      MYSQL_USER: $DB_USER
      MYSQL_PASSWORD: $DB_PASSWORD

  php:
    image: wodby/drupal-php:$PHP_TAG
    container_name: "${PROJECT_NAME}_php"
    environment:
      PHP_SENDMAIL_PATH: /usr/sbin/sendmail -t -i -S mailhog:1025
      DB_HOST: $DB_HOST
      DB_USER: $DB_USER
      DB_PASSWORD: $DB_PASSWORD
      DB_NAME: $DB_NAME
      DB_DRIVER: $DB_DRIVER
      PHP_XDEBUG: 1
      PHP_XDEBUG_DEFAULT_ENABLE: 1
      PHP_XDEBUG_REMOTE_CONNECT_BACK: 0
      PHP_XDEBUG_REMOTE_HOST: "10.0.75.1"
      PHP_XDEBUG_MAX_NESTING_LEVEL: 512
      PHP_FPM_USER: root
      PHP_FPM_GROUP: root
    volumes:
      - ./:/var/www/html
    user: root
    command: "php-fpm -R"

  nginx:
    image: wodby/drupal-nginx:$NGINX_TAG
    container_name: "${PROJECT_NAME}_nginx"
    depends_on:
      - php
    environment:
      NGINX_STATIC_CONTENT_OPEN_FILE_CACHE: "off"
      NGINX_ERROR_LOG_LEVEL: debug
      NGINX_BACKEND_HOST: php
      NGINX_SERVER_ROOT: /var/www/html/web
    volumes:
      - ./:/var/www/html
    labels:
      - 'traefik.backend=nginx'
      - 'traefik.port=80'
      - 'traefik.frontend.rule=Host:${PROJECT_BASE_URL}'

  adminer:
    container_name: "${PROJECT_NAME}_adminer"
    image: wodby/adminer:$ADMINER_TAG
    environment:
      ADMINER_SALT: adminer-salt
    labels:
      - 'traefik.backend=adminer'
      - 'traefik.port=9000'
      - 'traefik.frontend.rule=Host:adminer.${PROJECT_BASE_URL}'

  node:
    image: node:alpine
    container_name: "${PROJECT_NAME}_node"
    working_dir: /app
    labels:
      - 'traefik.backend=node'
      - 'traefik.port=3000'
      - 'traefik.frontend.rule=Host:front.${PROJECT_BASE_URL}'
    expose:
      - "3000"
    volumes:
      - ./front:/app
    command: sh -c 'npm install && npm run build && npm run start'

  portainer:
    image: portainer/portainer
    container_name: "${PROJECT_NAME}_portainer"
    command: --no-auth -H unix:///var/run/docker.sock
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock
    labels:
      - 'traefik.backend=portainer'
      - 'traefik.port=9000'
      - 'traefik.frontend.rule=Host:portainer.${PROJECT_BASE_URL}'

  traefik:
    image: traefik
    container_name: "${PROJECT_NAME}_traefik"
    command: -c /dev/null --web --docker --logLevel=INFO
    ports:
      - '8000:80'
      - '8080:8080' # Dashboard
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

.env file

### PROJECT SETTINGS

PROJECT_NAME=contentacms
PROJECT_BASE_URL=contentacms.docker.localhost

DB_NAME=drupal
DB_USER=drupal
DB_PASSWORD=drupal
DB_ROOT_PASSWORD=password
DB_HOST=mariadb
DB_DRIVER=mysql

### --- MARIADB ----

MARIADB_TAG=10.2-3.1.3
#MARIADB_TAG=10.1-3.1.3

### --- VANILLA DRUPAL ----
### [DRUPAL_VERSION]-[PHP_VERSION]-[STABILITY_TAG]

DRUPAL_TAG=8-7.1-4.2.4
#DRUPAL_TAG=8-7.0-4.2.4
#DRUPAL_TAG=7-7.1-4.2.4
#DRUPAL_TAG=7-7.0-4.2.4
#DRUPAL_TAG=7-5.6-4.2.4
#DRUPAL_TAG=6-5.6-4.2.4
#DRUPAL_TAG=6-5.3-4.2.4

### --- PHP ----

PHP_TAG=7.1-dev-4.2.3
#PHP_TAG=7.0-dev-4.2.3
#PHP_TAG=5.6-dev-4.2.3
#PHP_TAG=5.3-dev-4.2.3
#PHP_TAG=7.1-dev-macos-4.2.3
#PHP_TAG=7.0-dev-macos-4.2.3
#PHP_TAG=5.6-dev-macos-4.2.3
#PHP_TAG=5.3-dev-macos-4.2.3

### --- NGINX ----
### [DRUPAL_VERSION]-[NGINX_VERSION]-[STABILITY_TAG]

NGINX_TAG=8-1.13-4.0.3
#NGINX_TAG=7-1.13-4.0.3
#NGINX_TAG=6-1.13-4.0.3
#NGINX_TAG=8-1.12-4.0.3
#NGINX_TAG=7-1.12-4.0.3
#NGINX_TAG=6-1.12-4.0.3

### --- SOLR ---
### [DRUPAL_VERSION]-[SOLR_VERSION]-[STABILITY_TAG]

SOLR_TAG=8-6.6-2.4.0
#SOLR_TAG=8-6.5-2.4.0
#SOLR_TAG=8-6.4-2.4.0
#SOLR_TAG=8-6.3-2.4.0
#SOLR_TAG=8-5.5-2.4.0
#SOLR_TAG=8-7.0-2.4.0
#SOLR_TAG=8-7.1-2.4.0
#SOLR_TAG=8-7.2-2.4.0
#SOLR_TAG=7-5.4-2.4.0

### --- REDIS ---

REDIS_TAG=4.0-2.1.5
#REDIS_TAG=3.2-2.1.5

### --- POSTGRESQL ----

POSTGRES_TAG=10.1-1.3.0
#POSTGRES_TAG=9.6-1.3.0
#POSTGRES_TAG=9.5-1.3.0
#POSTGRES_TAG=9.4-1.3.0
#POSTGRES_TAG=9.3-1.3.0

### OTHERS

ADMINER_TAG=4.3-1.1.0
APACHE_TAG=2.4-3.0.4
ATHENAPDF_TAG=2.10.0
DRUPAL_NODE_TAG=1.0-1.0.0
MEMCACHED_TAG=1.4-2.0.0
RSYSLOG_TAG=latest
VARNISH_TAG=4.1-2.3.0
WEBGRIND_TAG=1.5-1.3.0

Logs output

NodeJS container:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

up to date in 30.746s

> [email protected] build /app
> nuxt build

2018-04-03T17:17:29.692Z nuxt:build Building...
2018-04-03T17:17:29.720Z nuxt:build App root: /app
2018-04-03T17:17:29.720Z nuxt:build Generating /app/.nuxt files...
2018-04-03T17:17:29.878Z nuxt:build Generating files...
2018-04-03T17:17:29.892Z nuxt:build Generating routes...
2018-04-03T17:17:29.995Z nuxt:build Building files...
 WARNING  Compiled with 1 warnings17:17:41

 warning

asset size limit: The following asset(s) exceed the recommended size limit (300 kB).
This can impact web performance.
Assets:
  img/server-unreachable.49499d2.gif (1.8 MB)
  vendor.718e749caad003fe291f.js (615 kB)

Hash: 1a437f820f9f50d3d013
Version: webpack 3.11.0
Time: 9070ms
                                                   Asset     Size  Chunks                    Chunk Names
pages/recipes-category/_category.abaab152700456ab584b.js  60.5 kB       4  [emitted]         pages/recipes-category/_category
                      img/server-unreachable.49499d2.gif   1.8 MB          [emitted]  [big]
                                    img/book.d98ea2b.svg  3.71 kB          [emitted]
                              img/difficulty.dc0d19c.svg  2.63 kB          [emitted]
                                  img/serves.ee57ed0.svg  2.73 kB          [emitted]
                     pages/index.a82be9229269d11be112.js  84.2 kB       0  [emitted]         pages/index
               pages/recipes/_id.3f414759873d4377d9a6.js  72.5 kB       1  [emitted]         pages/recipes/_id
             pages/recipes/index.5b97106bf7602c3b7bfc.js  75.6 kB       2  [emitted]         pages/recipes/index
      pages/recipes-latest/index.ec74bceaabb9ceb12db8.js  60.3 kB       3  [emitted]         pages/recipes-latest/index
                                   img/clock.54e3f46.svg  4.14 kB          [emitted]
         pages/all-recipes/index.f8532242afa8bbcc26fd.js    62 kB       5  [emitted]         pages/all-recipes/index
                 layouts/default.81a59b097d034cccef0b.js  32.7 kB       6  [emitted]         layouts/default
                   pages/contact.c18bb0e992b5adac90e6.js  15.8 kB       7  [emitted]         pages/contact
        pages/server-unreachable.66ecd45476b67727290e.js  11.9 kB       8  [emitted]         pages/server-unreachable
    pages/recipes-category/index.b8c736fbca57181004c9.js  2.53 kB       9  [emitted]         pages/recipes-category/index
                          vendor.718e749caad003fe291f.js   615 kB      10  [emitted]  [big]  vendor
                             app.254dc0aec3f3846b854c.js   106 kB      11  [emitted]         app
                        manifest.1a437f820f9f50d3d013.js  6.36 kB      12  [emitted]         manifest
 + 3 hidden assets

WARNING in asset size limit: The following asset(s) exceed the recommended size limit (300 kB).
This can impact web performance.
Assets:
  img/server-unreachable.49499d2.gif (1.8 MB)
  vendor.718e749caad003fe291f.js (615 kB)
Hash: 4cdc92d92ad52152db1e
Version: webpack 3.11.0
Time: 1381ms
             Asset    Size  Chunks             Chunk Names
server-bundle.json  436 kB          [emitted]
2018-04-03T17:17:42.613Z nuxt:build Building done

> [email protected] start /app
> nuxt start


 OPEN  http://localhost:3000

Traefik container:

time="2018-04-03T17:27:57Z" level=info msg="Using TOML configuration file /dev/null"
time="2018-04-03T17:27:57Z" level=info msg="Traefik version v1.4.6 built on 2018-01-02_12:27:08PM"
time="2018-04-03T17:27:57Z" level=info msg="Preparing server http &{Network: Address::80 TLS:<nil> Redirect:<nil> Auth:<nil> WhitelistSourceRange:[] Compress:false ProxyProtocol:<nil> ForwardedHeaders:0xc420797cc0} with readTimeout=0s writeTimeout=0s idleTimeout=3m0s"
time="2018-04-03T17:27:57Z" level=info msg="Starting provider *docker.Provider {"Watch":true,"Filename":"","Constraints":null,"Trace":false,"DebugLogGeneratedTemplate":false,"Endpoint":"unix:///var/run/docker.sock","Domain":"","TLS":null,"ExposedByDefault":true,"UseBindPortIP":false,"SwarmMode":false}"
time="2018-04-03T17:27:57Z" level=info msg="Starting server on :80"
time="2018-04-03T17:27:57Z" level=info msg="Starting provider *web.Provider {"Address":":8080","CertFile":"","KeyFile":"","ReadOnly":false,"Statistics":null,"Metrics":null,"Path":"/","Auth":null,"Debug":false,"CurrentConfigurations":{},"Stats":{"Uptime":"2018-04-03T17:27:57.6441104Z","Pid":1,"ResponseCounts":{},"TotalResponseCounts":{},"TotalResponseTime":"0001-01-01T00:00:00Z"},"StatsRecorder":null}"
time="2018-04-03T17:27:57Z" level=info msg="Server configuration reloaded on :80"
time="2018-04-03T17:28:05Z" level=warning msg="Error forwarding to http://172.31.0.7:3000, err: dial tcp 172.31.0.7:3000: getsockopt: connection refused"
time="2018-04-03T17:28:06Z" level=warning msg="Error forwarding to http://172.31.0.7:3000, err: dial tcp 172.31.0.7:3000: getsockopt: connection refused"
time="2018-04-03T17:28:07Z" level=warning msg="Error forwarding to http://172.31.0.7:3000, err: dial tcp 172.31.0.7:3000: getsockopt: connection refused"
time="2018-04-03T17:28:07Z" level=warning msg="Error forwarding to http://172.31.0.7:3000, err: dial tcp 172.31.0.7:3000: getsockopt: connection refused"
time="2018-04-03T17:28:07Z" level=warning msg="Error forwarding to http://172.31.0.7:3000, err: dial tcp 172.31.0.7:3000: getsockopt: connection refused"
time="2018-04-03T17:28:08Z" level=warning msg="Error forwarding to http://172.31.0.7:3000, err: dial tcp 172.31.0.7:3000: getsockopt: connection refused"
time="2018-04-03T17:28:08Z" level=warning msg="Error forwarding to http://172.31.0.7:3000, err: dial tcp 172.31.0.7:3000: getsockopt: connection refused"
time="2018-04-03T17:28:08Z" level=warning msg="Error forwarding to http://172.31.0.7:3000, err: dial tcp 172.31.0.7:3000: getsockopt: connection refused"
time="2018-04-03T17:28:08Z" level=warning msg="Error forwarding to http://172.31.0.7:3000, err: dial tcp 172.31.0.7:3000: getsockopt: connection refused"

rafatwork avatar Apr 03 '18 17:04 rafatwork

Same problem here :-(

Vacilando avatar Apr 03 '18 19:04 Vacilando

Try directly exposing port 3000 via ports: and see what's going on there

csandanov avatar Apr 04 '18 05:04 csandanov

Under traefik: and ports: added - '3000:80'

so traefik config in docker-compose.yml is:

  traefik:
    image: traefik
    container_name: "${PROJECT_NAME}_traefik"
    command: -c /dev/null --web --docker --logLevel=INFO
    ports:
      - '8000:80'
#      - '8080:8080' # Dashboard
      - '3000:80'
    volumes:
      - /var/run/docker.sock:/var/run/docker.sock

Node config in docker-compose.yml is:

  node:
    image: node:alpine
    container_name: "${PROJECT_NAME}_node"
    working_dir: /app
    labels:
      - 'traefik.backend=node'
      - 'traefik.port=3000'
      - 'traefik.frontend.rule=Host:front.${PROJECT_BASE_URL}'
    expose:
      - "3000"
    volumes:
      - ./contenta_vue_nuxt:/app
    command: sh -c 'npm install && npm run dev && npm run build && npm run start'

However, http://front.contentacms.docker.localhost:3000/ shows "Bad gateway" just like http://front.contentacms.docker.localhost:8000/

Vacilando avatar Apr 11 '18 14:04 Vacilando

You've exposed port 3000 on traefik, do this for node instead. What I'm suggesting is to make sure first that the node service works as expected without traefik domains.

csandanov avatar Apr 11 '18 18:04 csandanov

@csandanov do you mean adding

ports:
-  '3000'

for node?

Meanwhile, here's log from node (from portainer). Looks good but the question is what is the precise URL and port to browse to.

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):,
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"}),
,
up to date in 21.421s,
,
> [email protected] dev /app,
> nuxt,
,
2018-04-11T20:04:18.847Z nuxt:build App root: /app,
2018-04-11T20:04:18.849Z nuxt:build Generating /app/.nuxt files...,
2018-04-11T20:04:18.916Z nuxt:build Generating files...,
2018-04-11T20:04:18.924Z nuxt:build Generating routes...,
2018-04-11T20:04:18.988Z nuxt:build Building files...,
2018-04-11T20:04:22.380Z nuxt:build Adding webpack middleware...,
 DONE  Compiled successfully in -4268ms20:04:29,
,
,
 OPEN  http://localhost:3000,
,

Vacilando avatar Apr 11 '18 20:04 Vacilando

Still not solved; feedback welcome. Is there any other example of running a node app in docker4drupal?

Vacilando avatar Apr 24 '18 15:04 Vacilando

do you mean adding

yes but if you specify a single port an ephemeral high port will be automatically assigned, you can find it via docker-compose ps

in other words just make sure it works without using traefik or even docker compose file

csandanov avatar Apr 25 '18 06:04 csandanov

Node does run:

docker-compose ps

      Name                     Command               State               Ports
-------------------------------------------------------------------------------------------
forg_d8_mailhog     MailHog                          Up      1025/tcp, 8025/tcp
forg_d8_mariadb     /docker-entrypoint.sh --ch ...   Up      3306/tcp
forg_d8_nginx       /docker-entrypoint.sh sudo ...   Up      80/tcp
forg_d8_node        sh -c npm install && npm r ...   Up      0.0.0.0:32768->3000/tcp
forg_d8_php         /docker-entrypoint.sh sudo ...   Up      9000/tcp
forg_d8_pma         /run.sh phpmyadmin               Up      80/tcp, 9000/tcp
forg_d8_portainer   /portainer --no-auth -H un ...   Up      9000/tcp
forg_d8_sshd        /docker-entrypoint.sh sudo ...   Up      0.0.0.0:2222->22/tcp, 9000/tcp
forg_d8_traefik     /traefik -c /dev/null --we ...   Up      0.0.0.0:8000->80/tcp

Here the portainer log for node again:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})

up to date in 23.888s

> [email protected] dev /app
> nuxt

2018-05-15T22:28:32.632Z nuxt:build App root: /app
2018-05-15T22:28:32.634Z nuxt:build Generating /app/.nuxt files...
2018-05-15T22:28:32.708Z nuxt:build Generating files...
2018-05-15T22:28:32.716Z nuxt:build Generating routes...
2018-05-15T22:28:32.784Z nuxt:build Building files...
2018-05-15T22:28:36.294Z nuxt:build Adding webpack middleware...
 DONE  Compiled successfully in -4138ms22:28:43

 OPEN  http://localhost:3000

The question is on what URL can we access the site. (It's not http://localhost:3000.)

Vacilando avatar May 15 '18 22:05 Vacilando

It's not http://localhost:3000

why not? if you have webpack running on port 3000 in node container and you expose it to the host's port 3000 then it should work.

csandanov avatar May 17 '18 10:05 csandanov

Hello guys. I have the same issue. I tried by access the container using it's IP and port 3000, but I get a timeout.

I check inside the containers for the open ports, and port 3000 seems open. I did a wget localhost:3000 inside the container, and it worked just fine.

But, unfortunately I can't access the node server from my host machine. Any idea what to check?

Thank you for your help and time.

walkero-gr avatar Feb 21 '20 15:02 walkero-gr

as an addition to the above. If I add mailhog on the same stack with the node, then this is accessed just fine, but not node

traefik logs when creating the containers

local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="No entryPoint defined for this router, using the default one(s) instead: [http traefik]" routerName=pwa_mailhog@docker
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="No entryPoint defined for this router, using the default one(s) instead: [http traefik]" routerName=pwa_node@docker
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="No entryPoint defined for this router, using the default one(s) instead: [http traefik]" routerName=local_portainer@docker
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="No entryPoint defined for this router, using the default one(s) instead: [http traefik]" routerName=portainer-templates-development@docker
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="No entryPoint defined for this router, using the default one(s) instead: [http traefik]" routerName=traefik-development@docker
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating middleware" middlewareName=pipelining entryPointName=http routerName=pwa_mailhog@docker serviceName=pwa_mailhog middlewareType=Pipelining
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating load-balancer" entryPointName=http routerName=pwa_mailhog@docker serviceName=pwa_mailhog
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating server 0 http://172.18.0.4:8025" serviceName=pwa_mailhog serverName=0 entryPointName=http routerName=pwa_mailhog@docker
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Added outgoing tracing middleware pwa_mailhog" entryPointName=http routerName=pwa_mailhog@docker middlewareType=TracingForwarder middlewareName=tracing
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating middleware" entryPointName=http routerName=pwa_node@docker serviceName=pwa_node middlewareName=pipelining middlewareType=Pipelining
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating load-balancer" entryPointName=http routerName=pwa_node@docker serviceName=pwa_node
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating server 0 http://172.18.0.2:3000" entryPointName=http routerName=pwa_node@docker serviceName=pwa_node serverName=0
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Added outgoing tracing middleware pwa_node" middlewareName=tracing middlewareType=TracingForwarder entryPointName=http routerName=pwa_node@docker
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating middleware" middlewareName=pipelining middlewareType=Pipelining entryPointName=http routerName=local_portainer@docker serviceName=portainer-development
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating load-balancer" serviceName=portainer-development entryPointName=http routerName=local_portainer@docker
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating server 0 http://172.20.0.3:9000" entryPointName=http routerName=local_portainer@docker serviceName=portainer-development serverName=0
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Added outgoing tracing middleware portainer-development" middlewareType=TracingForwarder routerName=local_portainer@docker entryPointName=http middlewareName=tracing
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating middleware" middlewareName=pipelining middlewareType=Pipelining routerName=portainer-templates-development@docker serviceName=portainer-templates-development entryPointName=http
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating load-balancer" routerName=portainer-templates-development@docker serviceName=portainer-templates-development entryPointName=http
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating server 0 http://172.20.0.2:80" serverName=0 serviceName=portainer-templates-development entryPointName=http routerName=portainer-templates-development@docker
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Added outgoing tracing middleware portainer-templates-development" entryPointName=http routerName=portainer-templates-development@docker middlewareName=tracing middlewareType=TracingForwarder
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating middleware" entryPointName=http serviceName=traefik-development routerName=traefik-development@docker middlewareName=pipelining middlewareType=Pipelining
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating load-balancer" serviceName=traefik-development routerName=traefik-development@docker entryPointName=http
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating server 0 http://172.19.0.2:80" serviceName=traefik-development routerName=traefik-development@docker entryPointName=http serverName=0
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Added outgoing tracing middleware traefik-development" entryPointName=http routerName=traefik-development@docker middlewareName=tracing middlewareType=TracingForwarder
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating middleware" entryPointName=http middlewareName=traefik-internal-recovery middlewareType=Recovery
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Added outgoing tracing middleware dashboard@internal" entryPointName=traefik routerName=dashboard@internal middlewareName=tracing middlewareType=TracingForwarder
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating middleware" entryPointName=traefik routerName=dashboard@internal middlewareName=dashboard_stripprefix@internal middlewareType=StripPrefix
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Adding tracing to middleware" routerName=dashboard@internal middlewareName=dashboard_stripprefix@internal entryPointName=traefik
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating middleware" routerName=dashboard@internal entryPointName=traefik middlewareName=dashboard_redirect@internal middlewareType=RedirectRegex
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Setting up redirection from ^(http:\\/\\/[^:\\/]+(:\\d+)?)\\/$ to ${1}/dashboard/" entryPointName=traefik middlewareName=dashboard_redirect@internal middlewareType=RedirectRegex routerName=dashboard@internal
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Adding tracing to middleware" entryPointName=traefik routerName=dashboard@internal middlewareName=dashboard_redirect@internal
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Added outgoing tracing middleware api@internal" middlewareName=tracing middlewareType=TracingForwarder entryPointName=traefik routerName=api@internal
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="Creating middleware" entryPointName=traefik middlewareName=traefik-internal-recovery middlewareType=Recovery
local_traefik | time="2020-02-24T11:51:00Z" level=debug msg="No default certificate, generating one"

my docker-compose.yml

version: "3"

services:
  node:
    image: wodby/node:$NODE_TAG
    container_name: "${PROJECT_NAME}_node"
    environment:
      APP_ROOT: /var/www/html
    working_dir: /var/www/html
    labels:
      - "traefik.http.services.${PROJECT_NAME}_node.loadbalancer.server.port=3000"
      - "traefik.http.routers.${PROJECT_NAME}_node.rule=Host(`${PROJECT_BASE_URL}`)"
    expose:
      - "3000"
    volumes:
      - ./public_html:/var/www/html
    command: sh -c 'npm install && npm run dev'


  mailhog:
    image: mailhog/mailhog
    container_name: "${PROJECT_NAME}_mailhog"
    labels:
      - "traefik.http.services.${PROJECT_NAME}_mailhog.loadbalancer.server.port=8025"
      - "traefik.http.routers.${PROJECT_NAME}_mailhog.rule=Host(`mailhog.${PROJECT_BASE_URL}`)"

Any idea why the node is blocked by traefik?

walkero-gr avatar Feb 24 '20 11:02 walkero-gr

Tested the above setup on a Linux based machine and I get exactly the same results. 502 Bad Gateway on NodeJS container. There must be something missing in node container setup. And I use the latest docker4drupal files to set this up.

walkero-gr avatar Feb 25 '20 11:02 walkero-gr

found the problem. For the record. When you use nuxtjs, by default it listens to localhost, and that blocks everything outside the container. you need to run nuxtjs server like nuxt --hostname 0.0.0.0 --port 3000

walkero-gr avatar Feb 25 '20 15:02 walkero-gr

@walkero-gr thank you, this solution helped me

domambia avatar Mar 18 '21 10:03 domambia