I work with Traefik inside a docker-compose system. I use it to serve this app, where every component is inside a Docker container:
Typo: the frontend for Node API is actually named backend-recstars.traefik.me !
Here are links to my different (shortened) codes for this application:
- Node Dockerfile
What's the problem
I can successfully access my React application through Nginx, but my Node API keeps returning me a
I don't know why Traefik cannot reach my Node container, though it seems to be up and accessible:
What I tried
Adding these two labels to the Node docker service, but didn't change anything, even by changing the port to 80 (which is what Node listens to)
Any help will be greatly appreciated
Configuration seems fine as all containers are running on traefik network and Traefik Docker Configuration Discovery is set to the same network.
The Node Docker image does not expose a port, so Traefik does not know where to route to. So adding the port declaration via label should be one step to the solution.
We use purchased TLS/SSL certificates, in my experience we had to add
tls=true to make it work. But it seems for you it works for the other container without.
Make sure you have the right port
If this does not help, maybe try removing all the CORS stuff to see if it works without.
Thank you for your answer.
Actually the problem came from my NodeJS server which was effectively listening to the port 3000, but had an unneeded argument that prevented the server to listen to incoming requests:
const server = app.listen(port, 'localhost')
const server = app.listen(port)
My bad, hope it might help someone in the future
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.