﻿# Configure HAProxy for document server

> [HTML Version](haproxy-docs-server.html)

The architecture of a highly available BRIX cluster involves the interaction of BRIX application microservices with the R7-Office document server, ONLYOFFICE Docs Server. The HAProxy configuration discussed in this article assumes even load balancing of traffic between the two document servers.

## Example HAProxy configuration for document server

HAProxy evenly distributes client connections arriving at \[OBJECT\] between the two document servers. 

Open the **haproxy.cfg** configuration file for editing using the command:

````
sudo nano /etc/haproxy/haproxy.cfg

````
Example configuration for load balancing between two document servers using HAProxy to add to the **haproxy.cfg **file:

````
\### Docs Server ###  
listen docsserver  
    bind r7office.your\_domain:80  
    mode http  
    balance leastconn  
    server r7office1 r7office-server1.your\_domain:80 check inter 2s  
    server r7office2 r7office-server2.your\_domain:80 check inter 2s  
\### Docs Server ###

````
Example HAProxy configuration using SSL

  
SSL can be enabled if OpenSSL support is embedded. In the \[OBJECT\] parameter, specify the path to the PEM file containing the required certificates and associated private keys ([fullchain certificate](fullchain-sertificate.md)). If the file does not contain a private key, HAProxy will attempt to load the key from the same path with a .**key** suffix.

  
If a directory name is used instead of a PEM file, all files found in that directory will be loaded in alphabetical order, except for files ending in .**issuer**, .**ocsp**, or .**sctl** (reserved solutions). 

  
 In the \[OBJECT\] parameter, specify the path to the PEM file containing the root certificate. Read more in the Configuration Manual for the HAProxy version used. Example for [HAProxy 2.5](https://cbonte.github.io/haproxy-dconv/2.5/configuration.html#5.1-crt):  


````
\### Docs Server ###  
listen docsserver  
    bind r7office.your\_domain:443 ssl crt /etc/haproxy/ssl/r7office-server.your\_domain.pem  
    mode http  
    balance leastconn  
    server r7office1 r7office-server1.your\_domain:443 check inter 2s ssl crt /etc/haproxy/ssl/r7office-server.your\_domain.pem ca-file /etc/haproxy/ssl/rootCA\_your\_domain.pem  
    server r7office2 r7office-server2.your\_domain:443 check inter 2s ssl crt /etc/haproxy/ssl/r7office-server.your\_domain.pem ca-file /etc/haproxy/ssl/rootCA\_your\_domain.pem  
\### Docs Server ###
````

````
Restart HAProxy:

````
sudo systemctl restart haproxy
````