Has anyone played with a HAProxy/nginx/etc?
I could have sworn there was a how-to guide for a way to do distributed hosting, either via Docker or via multiple instances of Discourse all hitting a single high availability database server, but I can’t seem to find a guide for it.
Any thoughts? I’m currently serving a small single Discourse site, but am interested in learning as much as I can about scaling and load balancing of Discourse.
5 个赞
Found it , less than fifteen minutes after I posted. I’ll put any info on snags or clarifications that might be helpful into the conversation here.
The documentation is very fragmented. I’m going to attempt to pull it all together here.
Any chance I could get some input from @nx2zdk or @jspdng ?
This is an advanced setup. Don’t follow this unless you are experienced with Linux server administration and Docker.
Hello everyone!
If you don’t want to mess with the firewall rules and security of your server, you can configure your Docker multiple container setup with just links and no exposed ports!
This way you can share your data container (postgres/redis) with other containers without exposing it to the internet.
How to
Edit your data.yml file commenting all the expose …
Multiple Container setup
If you would like to connect web-only and data Discourse docker containers.
There is optional setting for this, which is, you could specify a links key in container configuration (yaml file) to link those containers together ( i.e. linking web-only and data container ).
This way is also known as Docker --link flag.
Usage:
If you are trying to link database container to your web container
Add the following section in containers/web.yml
links:
- link:
name:…
Info on avoiding port exposure:
Just in case anybody stumbles here for running several Discourse instances behind https://github.com/jwilder/nginx-proxy:
Set discourse to listen on a local link port and tell the proxy to use the container’s internal port 80 like
expose:
- "127.0.0.1:2836:80"
env:
VIRTUAL_PORT: '80'
Load balancing with nginx:
Enabling http2 on Debian:
Offline page setup:
This guide is intended for advanced users, who are already using nginx outside the docker container. By following this guide you make your setup more complicated and will loose some speed benefits like HTTP2 if you’re not running Ubuntu 16.04 or later. Proceed with caution!
When Discourse is rebuilding or starting up, your users will usually either see an error message from their browser…
[image]
…or a not-so-nice 502 error message from Nginx:
[image]
If you’re a perfectionist l…
Assma
2024 年12 月 18 日 22:27
5
我在别处找不到满意的答案。
我了解到,对于标准环境,推荐使用 Discourse 的独立安装,因为它简单且稳定。但是,为了提供高可用性,有人建议将独立模式扩展到多个容器(29413 ),有人则建议完全重新设计独立的部署。
问题 1:既然高可用性是关于复制服务(Web 和数据库)并提供可靠的故障转移,Discourse 是否提出了在容器内复制 Web 服务和数据库的解决方案?
问题 2:对于 Web 服务,需要负载均衡器来确保实例之间的负载均衡。Discourse 专家和社区有什么建议?
问题 3:对于容器化数据库的高可用性,管理 PostgreSQL 复制的首选方法是什么?
问题 4:Redis 的情况也一样。
pfaffman
(Jay Pfaffman)
2024 年12 月 19 日 19:56
6
有许多方法可以处理 PostgreSQL 故障转移。你可以使用任何你喜欢的方法。
Assma:
Discourse 专家和社区的建议是什么?
据我所知,CDCK 托管使用 HA-proxy。你可以使用任何你喜欢的负载均衡器,并(大部分)使用 /srv/status 作为就绪指示器。
1 个赞