Skip to content

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

@atulmy

Description

@atulmy

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
      - [email protected]

  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
      - [email protected]

  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!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions