skip to Main Content

I have a domain name https://example.com that points to a vps server on amazon lightsail. I have several applications i want to run. The apps are in vue js and some in spring and i am using nginx as the web server.

The landing page is basically an app running on port 3000 but using reverse proxy to display it at the root of example.com on port 80

I would like to run another app like:

example.com/one, example.com/two and example.com/three where one, two and three are applications each running inside a docker container.

How would i go about configuring my apps in this way keeping in mind the apps are running separately inside docker?

2

Answers


  1. Docker can only route to different ports. It can not determine the container by a http-path.
    You need a reverse proxy (RP).

    You have two options:

    1. Install RP on host
      You can install the RP on your host machine. There are many pros, like you can use the certbot for automatic lets encrypt certs. And you have the opportunity to use more docker-containers.
      For this you have to publish ports in docker to your hostmachine.

    2. Use your docker-nginx as RP
      You can also set your frontend as RP. Just put your docker-containers in a docker-network and add the RP-config to your nginx.

    Login or Signup to reply.
  2. I highly suggest using Caddy for this type of setup.
    Nginx is awesome and you could use that for the same purpose.
    But for what you want to do caddy will work perfectly.
    Just make sure to run each container on a different port.
    Then use caddy as a reverse proxy to each container:
    https://medium.com/bumps-from-a-little-front-end-programmer/caddy-reverse-proxy-tutorial-faa2ce22a9c6

    Lets say you have containers running on port 5000,8800 and 9000
    the you could do:

    example.com
    
    reverse_proxy /one localhost:5000
    reverse_proxy /two localhost:8800
    reverse_proxy /three localhost:9000
    

    Caddy is cool because it will also setup SSL via Letsencrypt.
    I didn’t have time or a server to test this now, but let me know if it works.

    God bless 🙂

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search