gilyes / docker-nginx-letsencrypt-sample

Dockerized Nginx + Let's Encrypt sample
https://gilyes.com/docker-nginx-letsencrypt
385 stars 185 forks source link

Question - Usage with IP address (without the domain) for a service #16

Open atulmy opened 4 years ago

atulmy commented 4 years ago

I've the following additional 3 services with following configuration:

version: "3"

volumes:
  CONFD:
  VHOSTD:
  NGINX-HTML:

services:
  nginx:
    image: nginx
    ports:
      - 80:80
      - 443:443
      - 5000:5000
    ...

  nginx-gen:
    image: jwilder/docker-gen
    ...

  letsencrypt-nginx-proxy-companion:
    image: jrcs/letsencrypt-nginx-proxy-companion
    ...

  api:
    image: api
    build: ./api
    expose:
        - 3000
    environment:
      - VIRTUAL_HOST=api.example.com
      - VIRTUAL_NETWORK=nginx-proxy
      - VIRTUAL_PORT=3000
      - LETSENCRYPT_HOST=api.example.com
      - LETSENCRYPT_EMAIL=email@example.com

  web:
    image: web
    build: ./web
    expose:
        - 4000
    environment:
      - VIRTUAL_HOST=web.example.com
      - VIRTUAL_NETWORK=nginx-proxy
      - VIRTUAL_PORT=4000
      - LETSENCRYPT_HOST=web.example.com
      - LETSENCRYPT_EMAIL=email@example.com

  admin:
    restart: always
    image: admin
    build: ./admin
    expose:
        - 5000

I want to map domains to api and web, however for admin, I'd just like to run it on IP:PORT (eg: http://178.10.10.5:5000)

Is there a way to do this?

The default.conf should contain following to make it work:

# rest of automatically generated nginx code by nginx.tmpl

upstream admin {
  server admin:5000;
}
server {
  listen 5000;
  listen [::]:5000;
  location / {
    proxy_pass http://admin;
  }
}

Any help would be highly appreciated!

atulmy commented 4 years ago

CC: @gilyes, just wanted to get your help on this