[root@k8s-master-node1 ERP]# cat Dockerfile-erp
FROM centos:centos7.9.2009
RUN rm -rf /etc/yum.repos.d/*
COPY yum /root/yum
COPY local.repo /etc/yum.repos.d/
RUN yum install -y java-1.8.0-*
ADD app.jar /root/
EXPOSE 9999
CMD ["java","-jar","/root/app.jar"]
[root@k8s-master-node1 ERP]# cat Dockerfile-nginx
FROM centos:centos7.9.2009
RUN rm -rf /etc/yum.repos.d/*
COPY local.repo /etc/yum.repos.d/
COPY yum /root/yum
RUN yum -y install nginx
ADD nginx /etc/nginx
EXPOSE 80
CMD ["nginx","-g","daemon off;"
docker-compose
[root@k8s-master-node1 ERP]# cat docker-compose.yaml
version: '3'
services:
mariadb:
image: erp-mariadb:v1.0
container_name: erp-mariadb
restart: always
ports:
- "3306:3306"
networks:
- erp-net
redis:
image: erp-redis:v1.0
container_name: erp-redis
restart: always
ports:
- "6379:6379"
networks:
- erp-net
nginx:
image: erp-nginx:v1.0
container_name: erp-nginx
restart: always
ports:
- "8080:80"
networks:
- erp-net
erp:
image: erp:v1.0
container_name: erp
restart: always
ports:
- "9999:9999"
networks:
- erp-net
networks:
erp-net:
nginx.conf
[root@k8s-master-node1 ERP]# cat nginx/nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
client_max_body_size 10m;
server {
listen 80;
location / {
root /app;
try_files $uri $uri/ /index.html $uri/ =404;
index index.html index.htm;
}
location /jshERP-boot/ {
proxy_pass http://erp-server:9999/jshERP-boot/;
proxy_set_header Host $host:$server_port;
}
}
}
[root@k8s-master-node1 ERP]# docker ps | grep erp
2f7a8ec20c8c erp-nginx:v1.0 "nginx -g 'daemon of…" 11 minutes ago Restarting (1) 29 seconds ago erp-nginx
c45f1d43148c erp-redis:v1.0 "/bin/sh -c 'redis-s…" 11 minutes ago Up 11 minutes 0.0.0.0:6379->6379/tcp, :::6379->6379/tcp erp-redis
154d8a083da3 erp:v1.0 "java -jar /root/app…" 11 minutes ago Restarting (1) 7 seconds ago erp
099eee888a84 erp-mariadb:v1.0 "mysqld_safe --user=…" 11 minutes ago Up 11 minutes 0.0.0.0:3306->3306/tcp, :::3306->3306/tcp erp-mariadb
[root@k8s-master-node1 ERP]# docker logs --tail 50 --follow --timestamps 2f7a8ec20c8c
2023-09-04T22:50:23.555442967Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:24.300262102Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:24.958909792Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:25.816261977Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:27.062843605Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:29.151060619Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:32.750432089Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:39.618648965Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:52.873706828Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:51:18.882991669Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
How to fix it?
It seems that the error message you received is related to the configuration of your Nginx server. The error message indicates that the host “erp-server” is not found in the upstream section of your Nginx configuration file 1.
[root@k8s-master-node1 ERP]# docker logs --tail 50 --follow --timestamps 2f7a8ec20c8c
2023-09-04T22:50:23.555442967Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:24.300262102Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:24.958909792Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:25.816261977Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
2023-09-04T22:50:27.062843605Z nginx: [emerg] host not found in upstream "erp-server" in /etc/nginx/nginx.conf:24
line 22
proxy_pass http://erp-server:9999/jshERP-boot/;
I don't know if there's any confusion about segments. I don't have a lot of grounding in that.
As you mentioned, the nginx config seemed to be wrong.
proxy_pass http://erp-server:9999/jshERP-boot/;
The erp-server
is not listed in your compose
file. You should change it to the service you have. In this case erp
.
proxy_pass http://erp:9999/jshERP-boot/;