I run nodejs on localhost while nginx runs as a docker container with docker-compose
I can't make any connections to the node js app:
nginx.conf
worker_processes 1;
events {
worker_connections 1024;
}
http {
server {
listen 80;
server_name licensing.cluster-ops.co;
location / {
proxy_pass http://md_license_server:3005;
proxy_set_header Host $host;
}
}
}
docker-compose.yml
version: "3.3"
services:
md_license_server:
image: root/md-license-server
expose:
- 3005
ports:
- 3005:3005
nginx:
image: nginx:latest
container_name: nginx
ports:
- 80:80
- 443:443
volumes:
- /etc/ssl/certs:/etc/ssl/certs
- /etc/ssl/private:/etc/ssl/private
- /root/docker/nginx.conf:/etc/nginx/nginx.conf
I tried everything out there.
extra_hosts: - "host.docker.internal:127.0.0.1"
^this won't work.
The node app works perfectly fine on localhost.. I tried to make somem curl calls and the response was ok.
This is the error message i get from docker:
2021/12/06 14:29:06 [error] 24#24: *3 connect() failed (111: Connection refused)
while connecting to upstream, client: 139.59.147.204, server:
localhost, request: "GET /ping HTTP/1.1", upstream: "http://172.19.0.2:3005
/ping", host:...
It looks like "172.19.0.2:3005" is either the IP of the md_license service.
running
docker-compose exec md_license_server curl http://localhost:3005/ping returns true
which means the node server works within the container.
I feel this is something about nginx.