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.