I am learning NGINX Reverse Proxy from https://www.freecodecamp.org/news/docker-nginx-letsencrypt-easy-secure-reverse-proxy-40165ba3aee2/
I use dockerized NGINX. My end goal is to host Odoo with HTTPS. Right now, I am learning how to reverse proxy (Odoo use port 8069, e.g. 127.0.0.1:8069 to access Odoo instead of 127.0.0.1)
I understand the concept behind Proxy and Reverse Proxy but I still have not figured out about the technical part such as upstream. I am actually curious why the article require upstream (article related to reverse proxy I seen on on stackoverflow did not use upstream)
Expected result:
By visiting example.com, reverse proxy will sending request (by user) coming from example.com to 127.0.0.1:8069
Actual result:
NGINX container commit suicide.
sudo docker-compose up reverse
output
Starting reverse ... done
Attaching to reverse
reverse | 2020/04/22 14:04:05 [emerg] 1#1: host not found in upstream "odoo:8069" in /etc/nginx/conf.d/sites-enabled/odoo.conf:2
reverse | nginx: [emerg] host not found in upstream "odoo:8069" in /etc/nginx/conf.d/sites-enabled/odoo.conf:2
reverse exited with code 1
cat /etc/nginx/conf.d/sites-available/odoo.conf
output
upstream odoo {
server odoo:8069;
}
server {
listen 80;
server_name example.com;
location / {
proxy_pass http://odoo;
}
}
---- Update as requested by @user2932688
cat docker-compose.yml
output
version: '3'
services:
reverse:
container_name: reverse
hostname: reverse
image: nginx:1.16.1
ports:
- 80:80
- 443:443
volumes:
- ./volumes/nginx/config/nginx.conf:/etc/nginx/nginx.conf
- ./volumes/nginx/config/conf.d:/etc/nginx/conf.d
- ./volumes/nginx/certs:/etc/ssl/private
web:
image: odoo:13.0
container_name: odoo
depends_on:
- db
ports:
- "8069:8069"
volumes:
- odoo-web-data:/var/lib/odoo
- ./volumes/odoo/config:/etc/odoo
- ./volumes/odoo/addons:/mnt/extra-addons
environment:
- HOST=db
- USER=odoo
- PASSWORD=odoo
db:
image: postgres:11.7
environment:
- POSTGRES_DB=postgres
- POSTGRES_PASSWORD=odoo
- POSTGRES_USER=odoo
- PGDATA=/var/lib/postgresql/data/pgdata
volumes:
- odoo-db-data:/var/lib/postgresql/data/pgdata
volumes:
odoo-web-data:
odoo-db-data:
sudo docker-compose up
output (running services: reverse, web, db)
Actual result: Reverse container commit suicide.
sudo docker-compose up
Creating network "docker-odoo-https_default" with the default driver
Creating volume "docker-odoo-https_odoo-web-data" with default driver
Creating volume "docker-odoo-https_odoo-db-data" with default driver
Creating reverse ... done
Creating docker-odoo-https_db_1 ... done
Creating odoo ... done
Attaching to reverse, docker-odoo-https_db_1, odoo
... reverse | 2020/04/22 15:23:27 [emerg] 1#1: host not found in upstream "odoo:8 069" in /etc/nginx/conf.d/sites-enabled/odoo.conf:2 reverse | nginx: [emerg] host not found in upstream "odoo:8069" in /etc/nginx /conf.d/sites-enabled/odoo.conf:2