我们有多个应用程序在单一的vultr云实例上,但它只有一个默认的健康检查,用于一个带有SSL证书的https loadBalancer。
因此,我们使用nginx配置了多个指定了/backend的http URL,并使用docker-compose运行,使应用程序可以在单个网络上运行。
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;
}
}
}后端url分别为http://instance-ip/、http://instance-ip/chat、http://instance-ip/auth
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一切运行正常,我们可以通过nginx默认端口80访问应用程序,使用上述后端URL。
但我们的意图是以某种方式将nginx与LoadBalancer中的HTTPS连接起来,它应该像
例如:https://qa.example.com/、https://qa.example.com/chat、https://qa.example.com/auth
发布于 2021-06-03 22:49:59
您要做的是在Vultr负载均衡器上设置一个转发规则。
实例上TLS的转发规则443->443
LB上TLS的转发规则443->80。
这将使LB将定义的LB端口上的所有传入流量转发到您的NGINX定义的端口。然后,您的nginx实例应该将该位置路由到您定义的适当proxy_pass。
至于运行状况,check...Vultr负载均衡器只有一次运行状况检查,因为它们被设计为与LB后面的单个应用程序一起工作。但是,您可以有一个/health端点,当命中时,它将检查所有其他应用程序的状态,如果它们都在运行,则返回200 ok。
我们在https://www.vultr.com/docs/vultr-load-balancers上提供了一些详细的文档
我是Vultr负载均衡器的技术负责人。
https://stackoverflow.com/questions/67809694
复制相似问题