evertramos / nginx-proxy-automation

Automated docker nginx proxy integrated with letsencrypt.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

[BUG] 502 Bad gateway even specify the port

cod3rshotout opened this issue · comments

I have the following docker-compose file:

version: '3'
services:

backend:
    container_name: example_backend
    build: ./backend/
    ports:
    - '3005:3005'
    volumes:
    - ./uploads:/backend/public/uploads
    environment:
    - VIRTUAL_HOST= backend.example.com, www.backend.example.com
    - VIRTUAL_PORT=3005
    - LETSENCRYPT_HOST= backend.example.com, www.backend.example.com
    restart: always

frontend:
    container_name: example_frontend
    build: 
    context: ./frontend/
    ports:
    - '3001:80'
    depends_on:
    - backend
    environment:
    VIRTUAL_HOST: example.com, www.example.com
    LETSENCRYPT_HOST: example.com, www.example.com

networks:
default:
    external:
    name: proxy

I've replaced the domain with example for privacy reason. Essentially the backend service runs over a nodejs application using Strapi, and for some reason when I try to access to backend.example.com I get: 502 bad gateway even if I specify the port, this instead doesn't happen for the frontend which is working well (even this runs on nodejs).

This is the backend container:

if I exec in the container and curl http//:localhost:3005 I get the correct login page html, but why nginx-proxy is returning 502?