1

I'm making a JQuery Ajax call from React frontend to an Express backend. Frontend is served by nginx on port 80, backend is listening on port 3000. The call from react to express looks like this

$.ajax({
    url: "http://localhost:3000/events?lat="+latitude+"&lng="+longitude+"&distance=15000&sort=time&until=%2B1%20week",
    dataType: "json",
    cache: false,
    success: function(data) {
        this.replaceState({data: data.events});
    }.bind(this),
    error: function(xhr, status, err) {
        console.error(this.props.url, status, err.toString());
    }.bind(this)
});

When I try to do this on Windows 10 host, it works seamlessly, but when I deploy the containers to Digitalocean's docker image (Docker 1.12.2 on Ubuntu 14.04) the nginx server is not able to reach Express server: ERR_CONN_REFUSED

Curl localhost:80 and curl localhost:3000 from host are working fine. I'm able to ping between the containers,from inside the container's shell

sudo docker exec -i -t [container_id] /bin/bash

I tried to disable the firewall, but it's already disabled by default on this image.

sudo ufw disable

Any hints what to try next? I'm out of ideas.

user159815
  • 11
  • 1
  • Are the react frontend and express backend being deployed on different containers? – Nehal J Wani Feb 13 '17 at 16:53
  • Yes, I'm using prebuild container with the Express service and I build my own frontend React. Then i deploy them using docker compose `web: build: . ports: - "80:80" fb-event-search: image: "tobilg/facebook-event-search" ports: - "3000:3000" environment: - "FEBL_ACCESS_TOKEN=OIghldqpw7RtJlEHMR42|hBt80g7uzjWU3mQyWlfi"` – user159815 Feb 13 '17 at 16:59
  • https://docs.docker.com/compose/networking/#/links – Nehal J Wani Feb 13 '17 at 17:00
  • I created new docker compose with the links attribute, but I am still not able to reach the Express service. Should I change the ajax call as well? How should the adress look like? This is my new docker-compose.yaml `version: '2' services: web: build: . ports: - "80:80" links: - "fb-event-search:fb" fb-event-search: image: "tobilg/facebook-event-search" expose: - "3000" environment: "FEBL_ACCESS_TOKEN=OIghldqpw7RtJlEHMR42|hBt80g7uzjWU3mQyWlfi‌​"` – user159815 Feb 22 '17 at 11:45

0 Answers0