# Discourse High Availability

**URL:** https://meta.discourse.org/t/discourse-high-availability/55091
**Category:** Self-hosting
**Created:** [January 3, 2017, 7:58am UTC](https://meta.discourse.org/t/discourse-high-availability/55091 "2017-01-03T07:58:36Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![jakimfett](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jakimfett/32/65817_2.png) [@jakimfett](https://meta.discourse.org/u/jakimfett)
#### Post date: [January 3, 2017, 7:58am UTC](https://meta.discourse.org/t/discourse-high-availability/55091/1 "2017-01-03T07:58:36Z")

</div>

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.

---

<div class="post-metadata">

### Author: ![jakimfett](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jakimfett/32/65817_2.png) [@jakimfett](https://meta.discourse.org/u/jakimfett)
#### Post date: [January 3, 2017, 8:11am UTC](https://meta.discourse.org/t/discourse-high-availability/55091/2 "2017-01-03T08:11:08Z")

</div>

[Found it](https://github.com/discourse/discourse_docker#single-container-vs-multiple-container), less than fifteen minutes after I posted. I’ll put any info on snags or clarifications that might be helpful into the conversation here.

---

<div class="post-metadata">

### Author: ![jakimfett](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jakimfett/32/65817_2.png) [@jakimfett](https://meta.discourse.org/u/jakimfett)
#### Post date: [January 3, 2017, 8:18am UTC](https://meta.discourse.org/t/discourse-high-availability/55091/3 "2017-01-03T08:18:48Z")

</div>

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?

> [@Use multiple Docker containers without exposing ports](https://meta.discourse.org/t/how-to-use-docker-multiple-containers-without-exposing-ports/22283/1):
>
> warning 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 …

> [@Linking containers for a multiple container setup](https://meta.discourse.org/t/linking-containers-for-a-multiple-container-setup/20867/1):
>
> 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](https://docs.docker.com/userguide/dockerlinks/) 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:…

---

<div class="post-metadata">

### Author: ![jakimfett](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/jakimfett/32/65817_2.png) [@jakimfett](https://meta.discourse.org/u/jakimfett)
#### Post date: [January 3, 2017, 3:49pm UTC](https://meta.discourse.org/t/discourse-high-availability/55091/4 "2017-01-03T15:49:49Z")

</div>

Info on avoiding port exposure:

> [@Use multiple Docker containers without exposing ports](https://meta.discourse.org/t/how-to-use-docker-multiple-containers-without-exposing-ports/22283/7):
>
> Just in case anybody stumbles here for running several Discourse instances behind [https://github.com/jwilder/nginx-proxy:](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:

> **[TCP load balancing with Nginx (SSL Pass-thru)](https://serversforhackers.com/c/tcp-load-balancing-with-nginx-ssl-pass-thru)**
>
> Learn to use Nginx 1.9.\* to load balance TCP traffic. In this case, we'll setup SSL Passthrough to pass SSL traffic received at the load balancer onto the web servers.

Enabling http2 on Debian:

> **[How to Enable HTTP2 on Debian 8 with Nginx Web Server](https://www.linuxbabe.com/nginx/enable-http2-debian-8-nginx-web-server)**
>
> HTTP2 is way faster than HTTP1.1. This tutorial shows how to enable HTTP2 with Nginx on Debian 8 server and explain some Nginx knowledge.

Offline page setup:

> [@Add an offline page to display when Discourse is rebuilding or starting up](https://meta.discourse.org/t/adding-an-offline-page-when-rebuilding/45238):
>
> warning 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 lose 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… …or a not-so-nice 502 error message from Nginx: If you’re a perfectionist …

---

<div class="post-metadata">

### Author: ![Assma](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/assma/32/473827_2.png) [@Assma](https://meta.discourse.org/u/Assma)
#### Post date: [December 18, 2024, 10:27pm UTC](https://meta.discourse.org/t/discourse-high-availability/55091/5 "2024-12-18T22:27:16Z")

</div>

I couldn’t find close answers elsewhere.  
I understood that Standalone installation of Discourse is recommended for its simplicity and robustness in standard environments. However, to provide High Availability, ones are suggesting bursting standalone mode into multiple containers ([29413](https://meta.discourse.org/t/move-from-standalone-container-to-separate-web-and-data-containers/29413)), others redesign fully separate deployments.

1. Question1: Since HA is about duplicating services (web and db) with reliable failover, does Discourse propose such solution where both web-services and DBs are replicated inside containers?
2. Question2: For web-services, a load-balancer would be needed to ensure charges equity between instances. What are Discourse experts and community recommendations?
3. Question3: For containerised-DB HA, what is the most preferable way to manage postgreSQL replication?
4. Question4: Same question for Redis.

---

<div class="post-metadata">

### Author: ![pfaffman](https://sea3.discourse-cdn.com/meta/user_avatar/meta.discourse.org/pfaffman/32/120154_2.png) [@pfaffman](https://meta.discourse.org/u/pfaffman)
#### Post date: [December 19, 2024, 7:56pm UTC](https://meta.discourse.org/t/discourse-high-availability/55091/6 "2024-12-19T19:56:22Z")

</div>

> [@Assma](#):
>
> does Discourse propose such solution where both web-services and DBs are replicated inside containers?

There are a bunch of ways to deal with postgres failover. You can use whatever you like.

> [@Assma](#):
>
> What are Discourse experts and community recommendations?

CDCK hosting uses HA-proxy, last I thought I knew. You can use any load balancer you like and (mostly) use `/srv/status` as a ready indicator.
