Traefik: Level=error msg=“field not found, node: mywebsite” providerName=docker
I was finally able to resolve it after some hours of working with my Line Manager.
The issue was that I defined port 3008
in the Nginx default.conf file and then defined port 3004
in the Gatsby application's docker-compose.yml file. This did not allow traffic into the application from Traefik reverse proxy. since both ports were different.
Solution 1:
Simply defining the same port of 3008
in the Nginx default.conf and in the Gatsby application's docker-compose.yml file fixed it:
Nginx's defualt.conf
server { listen 3008; add_header Cache-Control no-cache; location / { root /usr/share/nginx/html; index index.html index.htm; try_files $uri $uri/ /index.html; expires -1; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; }}
Gatsby application's docker-compose.yml
version: "3"services: web: image: my-website build: context: . dockerfile: Dockerfile expose: - "3004" labels: - traefik.enable=true - traefik.http.routers.mywebsite.rule=Host(`mywebsite.com`) - traefik.http.services.educollectwebsite.loadbalancer.server.port=3008 restart: always volumes: - .:/appnetworks: default: external: name: traefik-proxy
Solution 2:
Defining the default port in Traefik which is port 80
in the Nginx default.conf and in the Gatsby application's docker-compose.yml file fixed it. This is more preferable when deploying static applications since it helps me to assume a reasonable default for the application.
Nginx's defualt.conf
server { listen 80; add_header Cache-Control no-cache; location / { root /usr/share/nginx/html; index index.html index.htm; try_files $uri $uri/ /index.html; expires -1; } error_page 500 502 503 504 /50x.html; location = /50x.html { root /usr/share/nginx/html; }}
Gatsby application's docker-compose.yml
version: "3"services: web: image: my-website build: context: . dockerfile: Dockerfile expose: - "80" labels: - traefik.enable=true - traefik.http.routers.mywebsite.rule=Host(`mywebsite.com`) restart: always volumes: - .:/appnetworks: default: external: name: traefik-proxy
Note: Using the same port with Traefik which is port 80 in the application, invalidates the need for a Traefik loadbalancer service.
- traefik.http.services.educollectwebsite.loadbalancer.server.port=80
That's all.
I hope this helps