我正在为 NGINX 设置配置,但不断收到以下错误:
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>"
我曾尝试过针对这里提出的不同问题的解决方案,但尚未找到解决方案。
Nginx 配置是
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 组成:
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:
这里提到的应用程序是一个 Django Web 应用程序。
如果你们能帮助我找到这个问题那就太好了。