Caprover: How to reverse proxy other containers not managed by CapRover?

Created on 23 May 2020  路  4Comments  路  Source: caprover/caprover

IMPORTANT:
Please quickly search the existing issues and make sure that you're not create a duplicate issue. If you have a quesetion about a particular Dockerfile and deployment, change your questions to Dockerfile and post it where appropriate such as StackOverflow. This is a Docker question, not a CapRover specific issue.


Please clearly state your question:

I have a container called container-001 that has mapping 8081:8080, so I can access the web server in it via http://mydomain.com:8081. Due to some issues it's not an option to deploy the container with CapRover, so it's launched with Docker Compose.

This doesn't feel clean and I want to avoid exposing port 8081 externally, only use CapRover to reverse proxy this container and enable HTTPS for https://my-server.mydomain.com.

I tried to set up a nginx One-Click application with CapRover but don't understand how I can connect it to container-001 which is not managed by CapRover.

How can I set up a reverse proxy for other containers not managed by CapRover inside CapRover?

question

Most helpful comment

Try this: https://docs.docker.com/compose/networking/#use-a-pre-existing-network

All 4 comments

It should be possible.

1) Make sure your container is attached to CapRover overlay network captain-overlay-network
2) Create the nginx reverser proxy app
3) for upstream domain use http://container-001:8080

@githubsaturn Sorry to bother again, but how should I attach my container to captain-overlay-network with Docker compose?

I found this example, but not sure where I should specify captain-overlay-network. Haven't found much documentation on this.

I tried to add it to networks but Docker tells me ERROR: Service "container-001" uses an undefined network "captain-overlay-network".

version: "3.3"
services:
  container-001:
    image: publisher/docker-image
    container_name: container-001
    networks:
      - captain-overlay-network

Try this: https://docs.docker.com/compose/networking/#use-a-pre-existing-network

Thank you, it worked!!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dgpokl picture dgpokl  路  3Comments

lohazo picture lohazo  路  6Comments

drmrbrewer picture drmrbrewer  路  6Comments

gingerlime picture gingerlime  路  6Comments

Kimkykie picture Kimkykie  路  5Comments