socket hangup with nodejs proxy to communicate front end to backend service

5/5/2018

I have 2 containers - frontend_service is a nodejs frontend application built using react. I have a backend_service which has my business logic and communicates to MongoDB. The frontend communications to the backend via a proxy. I try to communicate to the backend service via the self-discovered service name in my cluster.

For example, I have code that calls the user api axios.get(/api/v1/users${window.location.search}).then

the frontend express server proxies that request to the backend service like so

// using http-proxy
      app.all('/api/v1', (req, res) => {
        res.set('Access-Control-Allow-Origin', '*');
        apiProxy.web(req, res, { target: 'http://backend_service', changeOrigin: true });
      });

I have setup my backend and frontend services in kubernetes, however, when the api/v1 is called from my app the request does not go through and times out like it cannot resolve the DNS. I get a socket hang up error

The weird thing is that if I enter the running frontend docker container and curl http://backend_service it works as expected.

I'm super confused why the request does not go through when executed via the http-proxy in my express server

-- Decrypter
http-proxy
kubernetes
node.js

0 Answers