1

I am setting up a configuration for NGINX but I am constantly getting the following error:

8#8: *698 connect() failed (111: Connection refused) while connecting to upstream, client: <IP1>, server: <domain>, request: "GET /sito/wp-includes/wlwmanifest.xml HTTP/1.1", upstream: "uwsgi://<IP2>:9000", host: "<domain>"

I have tried solutions from different questions already asked here but not yet reached the solution.

Nginx Configuration is

server {
    listen 443 ssl http2;
    server_name example.com  www.example.com;
    ssl_certificate /etc/nginx/certs/example.com.crt;
    ssl_certificate_key /etc/nginx/certs/example.com.key;

    location /static {
        alias /vol/static;
    }

    location / {
        uwsgi_pass ${APP_HOST}:${APP_PORT};
        include /etc/nginx/uwsgi_params;

        client_max_body_size 10M;
    }
}

server {
    listen 80;
    server_name example.com www.example.com;

    location / {
        return 301 https://example.com;
    }

}

Nginx Dockerfile:

FROM nginx:1.21.3
LABEL maintainer="example"

COPY ./default.conf.tpl /etc/nginx/default.conf.tpl
COPY ./uwsgi_params /etc/nginx/uwsgi_params
COPY ./certs/example.com.crt /etc/nginx/certs/
COPY ./certs/example.com.key /etc/nginx/certs/
COPY ./certs/example.com.pem /etc/nginx/certs/
COPY ./run.sh /run.sh

ENV APP_HOST=app
ENV APP_PORT=9000

# USER root

RUN mkdir -p /vol/static && \
    chmod 755 /vol/static && \
    touch /etc/nginx/conf.d/default.conf && \
    chown nginx:nginx /etc/nginx/conf.d/default.conf && \
    chmod +x /run.sh && \
    chmod +r /etc/nginx/certs/example.com.crt && \
    chmod +r /etc/nginx/certs/example.com.pem && \
    chmod +r /etc/nginx/certs/example.com.key

VOLUME /vol/static

# USER nginx

CMD ["/run.sh"]

Docker-Compose:

version: "3.3"

services:
    app:
        build:
            context: .
        restart: always
        volumes:
            - static-data:/vol/web
        environment:
            - *some environment variables*

    proxy:
        build:
            context: ./proxy
        restart: always
        depends_on:
            - app
        ports:
            - "80:80"
            - "443:443"
        volumes:
            - static-data:/vol/static
            - ./proxy/certs:/etc/nginx/certs


volumes:
    static-data:

The app mentioned here is a Django web app.

It would be really great if you guys could help me find the issue here.

  • 2
    `connection refused` means nothing is listening on the target ip/port. Make sure your application on the backend is running and is listening on the correct port and interface. – Gerald Schneider Aug 27 '22 at 08:44
  • I dont see here a relationship for business environment or equipment. a private WordPress isn't on topic for serverfault.com. But might be on topic on superuser.com – djdomi Aug 27 '22 at 09:00
  • @GeraldSchneider I understand that. But what bugs me more is that it was working fine earlier. I am just changing from domain A to domain B. I was under the impression that I have to just change all references and certificates. I committed both versions on different branches and did a git diff. There is no difference in the code where I am defining ports – Japkeerat Singh Aug 27 '22 at 09:01
  • Well, the issue is in the `app` container. You are providing no information about it. – Gerald Schneider Aug 27 '22 at 09:52

0 Answers0