0

I am using docker compose and have one nginx container serving as reverse proxy. It works great with other peer docker containers, but I want to expose another domain that is run locally on the host (golang) and not inside another docker container.

Can't find how to achieve that atm

my docker-compose looks like

services:
  proxy:
    image: nginx:1.19.10
    restart: on-failure
    volumes:
      - ./proxy/nginx.conf:/etc/nginx/nginx.conf
      - ./proxy/sites/:/etc/nginx/sites/
      - /etc/letsencrypt/:/etc/letsencrypt:ro
    expose:
      - 80
      - 443
    ports:
      - "80:80"
      - "443:443"
    container_name: "kj_proxy"

   supersite:
    // some definition here for a node website

Question is, how can I refer inside the nginx configuration to the host ? I can complete all configuration of server but cannot access form inside docker container the host port 10000 where the site is served

PS: It is very important that I can access both the host and other docker containers like I do currently by their service name. For the moment it works great accessing supersite:80 from inside my nginx container. This needs to still work + accessing the host machine like example "dockerhostwhatever:10000" for another nginx server rule

Kristi Jorgji
  • 1,154
  • 1
  • 14
  • 39
  • On MacOS and Windows, you can use a special hostname `host.docker.internal`. Native-Linux hosts are a little more involved. The linked question has more details. – David Maze Jul 11 '22 at 14:03
  • My comment was deleted am remaking it. First thanks for the reply but I think you rushed a little in closing my question as provided answer doewsn't work. I checked link and added in docker-compose ` extra_hosts: - "host.docker.internal:host-gateway"` then restarted rebuild and still can't ping `host.docker.internal curl: (6) Could not resolve host: host.docker.internal ` – Kristi Jorgji Jul 11 '22 at 14:22

0 Answers0