blacklabelops-legacy / nginx

Dockerized Ready-To-Go Nginx Reverse Proxy. Let's encrypt Support!
MIT License
95 stars 41 forks source link

Question: Is there a dynamic solution for same host port-forwarding? #15

Closed mattmeye closed 7 years ago

mattmeye commented 7 years ago

hello,

i use your proxy template for simple port-forwarding, e.g. docker-elk (port 6501 for kibana) on the same host

version: '2'
services:
  nginx-proxy:
    image: blacklabelops/nginx
    ports:
      - "80:80"
    environment:
      - "SERVER1REVERSE_PROXY_LOCATION1=/"
      - "SERVER1REVERSE_PROXY_PASS1=http://HOSTIP:5601"

I have to replace HOSTIP with the mashine ip. Is there a dynamic solution?

blacklabelops commented 7 years ago

Is Kibana:

mattmeye commented 7 years ago

A docker container in some other docker-compose file?

yes

But i dont want to use https://docs.docker.com/compose/extends I would like to restart individual services independently.

blacklabelops commented 7 years ago

Yes, that's possible.

  1. Give the kibana container a unique name.
  2. Put both container on the same docker network.
  3. Use container name as hostname.

Example First:

version: '2'

services:
  kibana:
    image: kibana
    container_name: kibana

Container has name kibana

Example Second:

You just have to start both docker-compose file inside the same compose project and they will be on the same network:

$ docker-compose --project-name kibana up -d

Will start a default network with the compose project prefix `kibana``

Example Third:

Use kibana as hostname:

version: '2'
services:
  nginx-proxy:
    image: blacklabelops/nginx
    ports:
      - "80:80"
    environment:
      - "SERVER1REVERSE_PROXY_LOCATION1=/"
      - "SERVER1REVERSE_PROXY_PASS1=http://kibana:5601"
blacklabelops commented 7 years ago

Closed because of inactivity.