I want to use nginx to mapping the port from outside my ec2 server to "website" service I defined in docker-compose.yml as
website:
build: .
command: >
gunicorn -c "python:config.gunicorn" "project.app:create_app()"
environment:
PYTHONUNBUFFERED: 'true'
volumes:
- '.:/project'
ports:
- '5000:5000'
expose:
- "5000"
restart: always
and nginx service build as
nginx:
build:
dockerfile: Dockerfile
context: ./nginx
ports:
- '3000:80'
- '443:443'
command: nginx -t -c /etc/nginx/default.conf
Dockerfile
FROM nginx:1.17.1
COPY ./default.conf /etc/nginx/default.conf
CMD ["nginx", "-g", "daemon off;"]
the test command return as successfully , then failed unexpected. How can I solve this problem?
nginx_1 | nginx: the configuration file /etc/nginx/default.conf syntax is ok
nginx_1 | nginx: configuration file /etc/nginx/default.conf test is successful
redis_1 | 1:C 21 Jul 2019 13:59:37.511 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo
redis_1 | 1:C 21 Jul 2019 13:59:37.512 # Redis version=5.0.5, bits=64, commit=00000000, modified=0, pid=1, just started
redis_1 | 1:C 21 Jul 2019 13:59:37.512 # Configuration loaded
collection-pro_nginx_1 exited with code 0
I think the problem come from default.conf file
default.conf file is as below
events {
worker_connections 2048;
multi_accept on;
use epoll;
}
http{
upstream website {
server website:5000;
}
server {
listen 80;
location / {
proxy_pass http://website;
}
}
}
changed the service name nginx to nginx-container, now the error finally come, nginx: [emerg] host not found in upstream "website:5000" in /etc/nginx/default.conf:11
close to the victory