Cannot pass REST API queries to the docker container


(Webtrend Inc) #1

I have nginx in front of my docker container and am trying to access API without any success.

When I am inside the docker container, I can successfully make API queries. However when I am outside, I get “Connection reset by peer” error.

I am exposing port 3000 in the app.yml file as follows:

- "127.0.0.1:3000:3333"

Some relevant portion from nginx config on the server looks like this:

upstream discourse {
 server 127.0.0.1:8080;
}
upstream discourseapi {
 server 127.0.0.1:3000;
}

server {
    listen 3333;
    root /home/forge/forums/public;
    server_name myserver;
    charset utf-8;

         location / {
         include proxy_params;
         proxy_pass http://discourseapi;
         proxy_redirect off;
         proxy_http_version 1.1;
         proxy_set_header Upgrade $http_upgrade;
         proxy_set_header Connection "upgrade";
        }

}

If I try to access port 3000 from outside the container from the command line

curl -I  http://127.0.0.1:3000

I get this error

curl: (56) Recv failure: Connection reset by peer

Needless to say that any attempt to actually send the REST queries also result in the same error. Any Ideas on why the API requests are not passing to the container?

As I said earlier, if I am inside the app I am successfully able to execute the api queries.


(Kane York) #2

You may want to read this:


(Vinu Surendran) #3

Can you please paste the output of the following commands here?

docker ps
docker inspect #CONTAINERID#
Run this command in the host machine where docker container is running


(Webtrend Inc) #4

OK, folks. I have found a workaround for now which is good enough for me.

Instead of trying to pass the REST queries through the reverse proxy server, I am just using the ip address assigned to the docker container. It works as expected and serves my purpose. The only downside is that I can only call the API within the host itself. No remote access is possible. But I don’t need remote access so I am ok.