3

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
  • 2,784
  • 12
  • 38
  • 57
  • Order of middleware may matter according to this https://stackoverflow.com/questions/26632854/socket-hangup-while-posting-request-to-node-http-proxy-node-js?utm_medium=organic&utm_source=google_rich_qa&utm_campaign=google_rich_qa – Jason Livesay May 05 '18 at 07:33
  • Did you find a way to solve this? – Nicolas Nov 06 '19 at 15:25

0 Answers0