javascript: the nginx connection was rejected while connecting to the upstream connection

I have a server where I have implemented an API (Sinatra). I run that API on port 9292 and the proxy requests it.

I also need to deploy a static javascript file and its support resources. I do it on the same server.

All the information below has been anonymous.

The API endpoint is this:

server {
listen 80;
server_name api.myapp.com;

Location / {
proxy_pass http: // localhost: 9292;
}
}

and the final point that I am serving the JS is:

server {
listen 80;
server_name xsa.myapp.com;

Location / {
root / data / mydir / xsa;
}
}

The server "localhost: 3003" that you see in the error below is where I am referring to the JS.

2018/11/23 23:31:27 [error] 18720 # 0: * 32 connect () failed
(111: connection rejected) while connecting to the uplink,
client: 255.255.255.7, server: api.myapp.com,
request: "GET / api / v1 / sub / sub_ABCXYZ / info? token% 3D56f51132-
406b-4e06-a600-7379876446ed HTTP / 1.1 ", upstream:
"http: //[::1]: 9292 / api / v1 / sub / sub_ABCXYZ / info? Token% 3D56f51132
-406b-4e06-a600-7379876446ed ", host:" api.myapp.com ",
reference: "http://xsa.myapp.com/src/selector.html?
mfid = sub_ABCXYZ & location = http: // localhost: 3003 / "

So to recap:

  • Sinatra API on VM "x" with port 9292
  • The nginx server on the VM "x" serves a proxy on port 80 to the API for requests that reach "api.myapp.com"
  • the same nginx server also offers a javascript file on port 80 for requests that arrive at "xsa.myapp.com"

I can see the JS well in a browser, so in fact it is being served. It is in the dynamic things that it does in the instantiation that is causing the error.

I can also see that the Sinatra server in 9292 is in fact receiving the request and returning a 200. It seems that the problem is after this. So it does not even seem that the uplink is rejected. I've double checked that this answer is exactly the same response as when the JS is served locally (and it works).

* UPGRADE *

The "rejected connection" error actually DOES occur even when the JS is served locally and is functioning correctly, so it appears that the error is a false trail.