Jan 15, 2024
0
Level 1
host not found in upstream "app" in /etc/nginx/conf.d/default.conf:16(Docker)
i am trying to dockerize my project
when i run
docker compose up
it works fine and when i access my myphpadmin port(3400), it works fine but if i try to access my nginx port (8080) i get this error
This site can’t be reached
127.0.0.1 refused to connect.
same error with port(8081)
and when i run
docker log nginx
i get this message
host not found in upstream "app" in /etc/nginx/conf.d/default.conf:16
i have tried different method and i still get this message below is the content of my docker-compose.yml file
version: '3.8'
services:
nginx:
container_name: nginx
image: nginx:alpine
ports:
- "8080:80"
depends_on:
- app
- db
volumes:
- ./src:/var/www
- ./nginx/conf.d/:/etc/nginx/conf.d
db:
image: mysql
container_name: mysql
ports:
- "3307:3307"
volumes:
- ./mysql/data:/var/lib/mysql
environment:
- MYSQL_DATABASE=productservice
- MYSQL_ROOT_PASSWORD=password
phpmyadmin:
image: phpmyadmin/phpmyadmin
container_name: phpmyadmin
ports:
- "3400:80"
depends_on:
- db
app:
image: debian
container_name: debian
ports:
- "8081:80"
and this is the content of my default.conf file
server {
listen 80;
index index.php index.html index.html;
error_log /var/log/nginx/error.log;
access_log /var/log/nginx/access.log;
server_name localhost;
root /var/www/public;
location / {
try_files $uri $uri/ /index.php?$query_string;
}
location /index.php {
try_files $uri = 404;
fastcgi_split_path_info ^(.+\.php)(/.+)$;
fastcgi_pass app:9000;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_param PATH_INFO $fastcgi_path_info;
}
}
please what am i doing wrong, i am new to docker please help
Please or to participate in this conversation.