502 Bad Gatewaynginx/1.19.5reinstall portainer and recreate docker images to solve this isssue, but didnt work.how can i solve this issue?
i think something's wrong before collectstaticbecause if this issue was about collectstatic, webpage have been deployed with static files not applied.
gunicorn container logs
0 static files copied to '/home/loldb/staticfiles', 147 unmodified.Operations to perform: Apply all migrations: accountapp, admin, articleapp, auth, commentapp, contenttypes, profileapp, projectapp, sessions, subscribeappRunning migrations: No migrations to apply.0 static files copied to '/home/loldb/staticfiles', 147 unmodified.Operations to perform: Apply all migrations: accountapp, admin, articleapp, auth, commentapp, contenttypes, profileapp, projectapp, sessions, subscribeappRunning migrations: No migrations to apply.0 static files copied to '/home/loldb/staticfiles', 147 unmodified.Operations to perform: Apply all migrations: accountapp, admin, articleapp, auth, commentapp, contenttypes, profileapp, projectapp, sessions, subscribeappRunning migrations: No migrations to apply.0 static files copied to '/home/loldb/staticfiles', 147 unmodified.Operations to perform: Apply all migrations: accountapp, admin, articleapp, auth, commentapp, contenttypes, profileapp, projectapp, sessions, subscribeappRunning migrations: No migrations to apply.nginx logs
/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d//docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf10-listen-on-ipv6-by-default.sh: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh/docker-entrypoint.sh: Configuration complete; ready for start up2024/01/08 02:17:16 [emerg] 1#1: host not found in upstream "django_container_gunicorn" in /etc/nginx/nginx.conf:22nginx: [emerg] host not found in upstream "django_container_gunicorn" in /etc/nginx/nginx.conf:22/docker-entrypoint.sh: /docker-entrypoint.d/ is not empty, will attempt to perform configuration/docker-entrypoint.sh: Looking for shell scripts in /docker-entrypoint.d//docker-entrypoint.sh: Launching /docker-entrypoint.d/10-listen-on-ipv6-by-default.sh10-listen-on-ipv6-by-default.sh: Getting the checksum of /etc/nginx/conf.d/default.conf10-listen-on-ipv6-by-default.sh: Enabled listen on IPv6 in /etc/nginx/conf.d/default.conf/docker-entrypoint.sh: Launching /docker-entrypoint.d/20-envsubst-on-templates.sh/docker-entrypoint.sh: Configuration complete; ready for start up2024/01/08 02:17:34 [error] 29#29: *1 connect() failed (113: No route to host) while connecting to upstream, client: 10.0.0.2, server: , request: "GET / HTTP/1.1", upstream: "http://10.0.17.2:8000/", host: "172.31.42.96"10.0.0.2 - - [08/Jan/2024:02:17:34 +0000] "GET / HTTP/1.1" 502 157 "-" "ELB-HealthChecker/2.0"2024/01/08 02:17:36 [error] 29#29: *3 connect() failed (111: Connection refused) while connecting to upstream, client: 10.0.0.2, server: , request: "GET / HTTP/1.1", upstream: "http://10.0.17.2:8000/", host: "172.31.42.96"10.0.0.2 - - [08/Jan/2024:02:17:36 +0000] "GET / HTTP/1.1" 502 157 "-" "ELB-HealthChecker/2.0"10.0.0.2 - - [08/Jan/2024:02:17:44 +0000] "GET / HTTP/1.1" 499 0 "-" "ELB-HealthChecker/2.0"2024/01/08 02:17:51 [error] 29#29: *7 connect() failed (113: No route to host) while connecting to upstream, client: 10.0.0.2, server: , request: "GET / HTTP/1.1", upstream: "http://10.0.17.2:8000/", host: "172.31.42.96"10.0.0.2 - - [08/Jan/2024:02:17:51 +0000] "GET / HTTP/1.1" 502 157 "-" "ELB-HealthChecker/2.0"2024/01/08 02:18:04 [error] 29#29: *9 connect() failed (113: No route to host) while connecting to upstream, client: 10.0.0.2, server: , request: "GET / HTTP/1.1", upstream: "http://10.0.17.2:8000/", host: "172.31.42.96"10.0.0.2 - - [08/Jan/2024:02:18:04 +0000] "GET / HTTP/1.1" 502 157 "-" "ELB-HealthChecker/2.0"2024/01/08 02:18:08 [error] 29#29: *11 connect() failed (113: No route to host) while connecting to upstream, client: 10.0.0.2, server: , request: "GET / HTTP/1.1", upstream: "http://10.0.17.2:8000/", host: "172.31.42.96"10.0.0.2 - - [08/Jan/2024:02:18:08 +0000] "GET / HTTP/1.1" 502 157 "-" "ELB-HealthChecker/2.0"10.0.0.2 - - [08/Jan/2024:02:18:14 +0000] "GET / HTTP/1.1" 499 0 "-" "ELB-HealthChecker/2.0"2024/01/08 02:18:18 [error] 29#29: *15 connect() failed (111: Connection refused) while connecting to upstream, client: 10.0.0.2, server: , request: "GET / HTTP/1.1", upstream: "http://10.0.17.2:8000/", host: "172.31.42.96"10.0.0.2 - - [08/Jan/2024:02:18:18 +0000] "GET / HTTP/1.1" 502 157 "-" "ELB-HealthChecker/2.0"Django Settings
BASE_DIR = Path(__file__).resolve().parent.parent.parentSTATIC_URL = '/static/'STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')STATICFILES_DIRS = [ BASE_DIR / "static", ]Dockerfile
FROM python:3.9.0WORKDIR /home/loldb/RUN mkdir /root/.ssh/ && \ chmod 700 /root/.ssh/ && \ touch /root/.ssh/known_hosts && \ ssh-keyscan github.com >> /root/.ssh/known_hostsADD ./.ssh/id_rsa /root/.ssh/id_rsaRUN chmod 600 /root/.ssh/id_rsaRUN git clone git@github.com:----/----.git .RUN echo "delete caches!"COPY requirements.txt /home/loldb/requirements.txtRUN pip install -r requirements.txtRUN pip install gunicornRUN pip install mysqlclientEXPOSE 8000CMD ["bash", "-c", "python manage.py collectstatic --noinput --settings=loldb.settings.deploy && \ python manage.py migrate --settings=loldb.settings.deploy"]nginx.conf
worker_processes auto;events{}http { server { listen 80; include mime.types; location /static/ { alias /data/static/; } location /media/ { alias /data/media/; } location / { proxy_pass http://django_container_gunicorn:8000; proxy_set_header Host $host; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_connect_timeout 300s; proxy_read_timeout 600s; proxy_send_timeout 600s; proxy_buffers 8 16k; proxy_buffer_size 32k; } }}