Docker Compose Nginx Internal Server Error

  docker, docker-compose, flask, nginx, python

I have a flask app that I want to host on nginx in my docker compose file but when I do it gives me an Internal Server error

Here are some important files:

docker-compose.yml

version: "3.8"

services:
  th3pl4gu3:
    container_name: portfolix
    build: ./
    networks:
      - portfolix_net
    ports:
      - 8084:8084
    restart: always

  server:
    image: nginx:1.17.10
    container_name: nginx
    depends_on:
      - th3pl4gu3
    volumes:
      - ./reverse_proxy/nginx.conf:/etc/nginx/nginx.conf
    ports:
      - 80:80
    networks:
      - portfolix_net

networks:
  portfolix_net:
    name: portfolix_network
    driver: bridge

nginx.conf:

server {
listen 80;

location / {
    include uwsgi_params;
    uwsgi_pass th3pl4gu3:8084;
}
}

Flask Dockerfile

# Using python 3.8 in Alpine
FROM python:3.8-alpine3.11

# Set the working directory to /app
WORKDIR /app

# Copy the current directory contents into the container at /app
ADD . /app

# Dependencies for uWSGI
RUN apk add python3-dev build-base linux-headers pcre-dev && pip install -r requirements.txt && apk update

# In case bash is needed
#RUN apk add --no-cache bash

# Tell the port number the container should expose
EXPOSE 8084

# Run the command
ENTRYPOINT ["uwsgi", "app.ini"]

app.ini

[uwsgi]
module = run:app

master = true
processes = 5

http-socket = 0.0.0.0:8084
chmod-socket = 660
vacuum = true

die-on-term = true

Now when I run this docker-compose without the nginx service, it works, but i want it to run on nginx server. Any idea why i am geting the Internal Server Error?

Source: Docker Questions

LEAVE A COMMENT