I've created 2 containers for both, Django and Nginx. It's working perfectly on my desktop, but when I pull my images from Docker Hub in an AWS EC2 instence and run, I got this error:
/docker-entrypoint.sh: Configuration complete; ready for start up
2021/08/24 15:09:39 [emerg] 1#1: host not found in upstream "my_server:8000" in /etc/nginx/conf.d/default.conf:2
nginx: [emerg] host not found in upstream "my_server:8000" in /etc/nginx/conf.d/default.conf:2
Here is my docker-compose.yml
version: '3.7'
services:
my_server:
image: user/image-app
build:
context: .
env_file:
- ./.env
ports:
- "8000:8000"
nginx:
build: ./nginx
image: user/image-nginx
ports:
- "80:80"
depends_on:
- my_server
volumes:
static:
My default.conf file
upstream django {
server my_server:8000;
}
server {
listen 80;
location / {
proxy_pass http://django;
}
}
Even after I try to add a network and change to "8000:80" the Django ports like this:
version: '3.7'
services:
scrimmage:
image: user/image-app
build:
context: .
env_file:
- ./.env
ports:
- "8000:80"
networks:
- django_network
nginx:
build: ./nginx
image: user/image-nginx
container_name: nginx
ports:
- "80:80"
depends_on:
- scrimmage
networks:
- django_network
volumes:
static:
networks:
django_network:
driver: bridge
And change the the default.conf to this:
upstream django {
server my_server;
}
server {
listen 80;
location / {
proxy_pass http://django;
}
}
Still not working. Also this changes don't work at my local machine. The first configuration works fine locally, like I said before.