Report this

What is the reason for this report?

Nginx reverse proxy Connection refused

Posted on November 16, 2021

Hi guys I have spent hours trying to get two containers up & running correctly. Container 1: nginx reverse proxy Container 2: .net web api

Docker commands:

sudo docker network create --driver bridge tmpnetwork
sudo docker run -it -d --net tmpnetwork --rm -d -v /home/nginxfiles:/etc/nginx/conf.d --name revprox -p 80:80 nginx 
sudo docker run -it -d --net tmpnetwork --name playapi -p 8081:80 2fe9c1e579aa

The web api is up & running. This works fine: curl http://localhost:8081/weatherforecast and http://example.com:8081/weatherforecast

conf file:

server {
    listen        80;
    listen [::]:80;
    server_name example.com;
    location / {
        proxy_pass         http://127.0.0.1:8081;
        proxy_http_version 1.1;
        proxy_set_header   Upgrade $http_upgrade;
        proxy_set_header   Connection keep-alive;
        proxy_set_header   Host $host;
        proxy_cache_bypass $http_upgrade;
        proxy_set_header   X-Forwarded-For $proxy_add_x_forwarded_for;
        proxy_set_header   X-Forwarded-Proto $scheme;
    }
}

I have tried: ufw disable

sudo docker logs --tail=10 -f

Gives error: failed (111: Connection refused) while connecting to upstream, client: xxx

How do I troubleshoot this? Br

The developer cloud

Scale up as you grow — whether you're running one virtual machine or ten thousand.

Start building today

From GPU-powered inference and Kubernetes to managed databases and storage, get everything you need to build, scale, and deploy intelligent applications.