Nginx connectivity with vultr loadbalancer

385 views Asked by At

We had many applications on single vultr cloud instance, but it has only one default healthcheck for a single https loadBalancer with SSL certificate.

so we used nginx to configure mutliple /backend URL with http specified and running using docker-compose to make applications running on a single network.

 server {
    listen       80;
    listen  [::]:80;
    server_name  *.example.com;

    access_log  /var/log/nginx/host.access.log  main;

    location / {
        proxy_pass http://strapi-container:1337/;
    }
 
    location /chat {
        proxy_pass http://rocketchat-container:3000;

    }

    location /auth {
        proxy_pass http://keycloak-container:8080;
        proxy_set_header Host $host;
    }
  }
}

The backend url is http://instance-ip/, http://instance-ip/chat, http://instance-ip/auth respectively

  nginx:
    image: nginx:1.20
    container_name: nginx
    ports:
      - 80:80
    restart: unless-stopped
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/conf.d/default.conf
    depends_on:
      - strapi-cms
      - rocketchat
      - keycloak
    networks:
      - test-network

Everything works fine and we are able to access the applications through nginx default port 80 with the above backend URL's.

But our intentions is to somehow connect the nginx with HTTPS LoadBalancer in vultr, it should works as

For example: https://qa.example.com/, https://qa.example.com/chat, https://qa.example.com/auth

1

There are 1 answers

1
ddymko On

What you will want to do is setup a single forwarding rule on the Vultr Load Balancer.

Forwarding rule 443->443 for TLS on the instance

Forwarding rule 443->80 for TLS on the LB.

This will have the LB forward all incoming traffic on the defined LB port to your NGINX defined port. Then your nginx instance should route the the location to the appropriate proxy_pass you have defined.

As for the health check...Vultr Load Balancers only have a single health check as they were designed to work with single applications behind the LB. However, you could have a /health endpoint that when hit would check the status of all of your other applications and return 200 ok if they are all running.

We have some detailed docs available at https://www.vultr.com/docs/vultr-load-balancers

Full disclosure I am the Technical Lead on load balancers for Vultr.