express-http-proxy icon indicating copy to clipboard operation
express-http-proxy copied to clipboard

Cannot proxy requests to another service within docker-compose

Open crisguitar opened this issue 5 years ago • 1 comments

I created a proxy that works fine when running outside of a container but as soon as I try with docker compose I get 504 for all my requests:

const backendUri = process.env.BE_URI || "localhost" // either localhost or api in case of docker-compose

app.use(
  baseUri,
  proxy(`http://${backendUri}:8081`, {
    proxyReqOptDecorator: (proxyReqOpts, srcReq) => {
      // do something with request
      return proxyReqOpts;
    }
  })
);

I have seen similar issues closed but none with a fix or a comment on how to fix it.

Is anyone able to help?

Thanks!

crisguitar avatar Jan 04 '21 14:01 crisguitar

Could you post the docker-compose file?

Assuming you have had a look at https://docs.docker.com/compose/networking/

hpl002 avatar Jan 07 '21 14:01 hpl002