I am new experimenting with docker and nginx and it seems that i cannot make Nginx.
context:
- there is 3 docker container run on docker compose (Nginx, frontend, and a Api backend)
- the website works fine with the IP address
- using the domain name redirects to the serveur IP
Problem :
I cannot make ngnix to display the name domain in the url bar, it displays the server IP
Not sure if it a docker issue or nginx conf.
THe ngnix con :
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name domain-name.com ;
# Frontend
location / {
proxy_pass http://frontend-name:8080; # same name as network alias
}
# Backend
location /api {
proxy_pass http://backend-name:5000/; # <--- note this has an extra /
}
# You may need this to prevent return 404 recursion.
location = /404.html {
internal;
}
}
the docker compose file :
version : "3"
networks:
isolation-network:
driver: bridge
services :
frontend :
container_name : frontend
build: ./PersonalWebsite
ports :
- 8080:8080
networks:
isolation-network:
aliases:
- frontend-name
backend :
container_name : backend
build : ./API/test
ports :
- 5000:5000
networks:
isolation-network:
aliases:
- backend-name
nginx-proxy:
depends_on:
- frontend
- backend
image: nginx:alpine
volumes:
- ./nginx/default.conf:/etc/nginx/conf.d/default.conf
networks:
isolation-network:
aliases:
- proxy-name
ports:
- 80:80
- 443:443
any ideas ?
PS: not an experienced dev a curious guy