Unable to edit Confluence pages using HAProxy configuration
Asked by Celine Villafuerte:

Good day,

We are currently migrating our Confluence instance from IP to hostname; however, we are unable to edit pages due to this error:

![error.png](/t5/image/serverpage/image-id/34518i6473C26FB6E18C38/image-dimensions/326x100?v=v2 "error.png")

We suspect that it has something to do with Synchrony and its configuration mapping with HAProxy. In our previous IP instance, we used nginx with this configuration:

```
location /confluence {
 proxy_set_header X-Forwarded-Host $host;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-Server $host;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_pass http://confluence_web:8090;
 }

location /synchrony {
 proxy_set_header X-Forwarded-Host $host;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-Server $host;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_pass http://confluence_web:8091;
 proxy_http_version 1.1;
 proxy_set_header Upgrade $http_upgrade;
 proxy_set_header Connection "Upgrade";
 }
```

Everything works fine, but after migrating to HAProxy, even though Confluence is accessible using the DNS, we experienced editing issues as seen in the screenshot above. Our current haproxy.cfg configuration looks like this:

```
backend confluence_server
 mode http
 balance source
 option forwardfor

server confluence 107.105.134.53:8090 check


backend synchrony_server
 mode http
 balance source
 option forwardfor

server synchrony 107.105.134.53:8091 check
```

We are unsure if we converted the configurations properly. We already modified our server.xml located in **confluence-server/confluence_install/conf** which looks like this:

    <Connector port="8090"      protocol="org.apache.coyote.http11.Http11NioProtocol"     connectionTimeout="20000"     URIEncoding="UTF-8" acceptCount="10"
         enableLookups="false" debug="0"     redirectPort="443"     maxThreads="200" minSpareThreads="10"     scheme="http"     proxyName="mycompany.com"      proxyPort="80" />

We deployed the Confluence service using docker-compose and already exposed both 8090 and 8091 ports in our config file.

Any help is appreciated. Thank you.


Answers:
author: Dave Theodore [Coyote Creek Consulting]
body: It looks like you're running on Server, so I'll assume you have Synchrony and Confluence running on the same server. I'll also assume you are running a version later than 6.2. Earlier versions of Confluence 6 Collaborative Editing worked differently than modern versions, so if you are running 6.0 or 6.1, save yourself some hassle and upgrade to the latest version.

In your HAproxy config, you are setting a context for Confluence. This will make your URL look like:

```
http://confluence.domain.com/confluence/display/SPACE/Page+Name
```

You are also calling a context for Synchrony, which will make the Synchrony traffic go to:

```
http://confluence.domain.com/synchrony/heartbeat
```

Since you have a Confluence Context, you need the Synchrony traffic to go to:

```
http://confluence.domain.com/confluence/synchrony/heartbeat
```

In modern versions of Confluence, you don't need to do anything special with Synchrony any more, as Tomcat proxies it. Furthermore, there really is no good reason to run a Confluence Context with HAproxy sitting ahead of Confluence.

Try this setting and get rid of the Synchrony settings:

```
location / {
 proxy_set_header X-Forwarded-Host $host;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-Server $host;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_pass http://confluence_web:8090;
 }
```

comments: author: Celine Villafuerte
body: Thank you for your quick response. Unfortunately, we are using Confluence 6.0 and it worked fine with the synchrony path using nginx. But we need to migrate to a hotsname url which entails using HAProxy, but the config above does not work.

I also checked <http://domain.com/synchrony/heartbeat>, it returned "Ok", but we're still experiencing the same editing issues.


author: Dave Theodore [Coyote Creek Consulting]
body: It should work if you remove the context from the HAproxy config.

```
location / {
 proxy_set_header X-Forwarded-Host $host;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-Server $host;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_pass http://confluence_web:8090;
 }

location /synchrony {
 proxy_set_header X-Forwarded-Host $host;
 proxy_set_header X-Real-IP $remote_addr;
 proxy_set_header X-Forwarded-Server $host;
 proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
 proxy_pass http://confluence_web:8091;
 proxy_http_version 1.1;
 proxy_set_header Upgrade $http_upgrade;
 proxy_set_header Connection "Upgrade";
 }
```


author: Celine Villafuerte
body: Our domain name hosts several services so we need to have /confluence as its context. As of now, we temporarily set collaborative editing to limited since we are having problems with Synchrony.


author: Contegix Support
body: [@Dave Theodore \[Coyote Creek Consulting\]](/t5/user/viewprofilepage/user-id/853538)

your comments have location stanzas for nginx, not haproxy.

We too need to know if this route can work w/o any proxy running locally on the confluence server:
> Web --\> Haproxy server --\> Confluence server:8080

We do not run any proxy (apache, nginx, etc) on the confluence server. And Synchrony is running under the confluence pid, not standalone.

We do have this in confluence.cfg.xml, and i'm wondering if it should be set to False because we're not proxying 8081 anywhere:

```
 <property name="synchrony.proxy.enabled">true</property>
```

thanks!


author: bdegier
body: I have the exact same problem with Confluence. It first worked fine through nginx but I had to re-route the traffic through our HaProxy loadbalancers and now we have two problems:

* Very slow loading pages
* Publishing/editing pages either fails or takes a long time. If it fails it can take up to 5 tries before it suddenly works again.

All other traffic routed through HaProxy works fine. It feels like the websocket connections aren't setup properly sometimes.

```
backend docs
balance roundrobin
mode http
option forwardfor
server docker-ams7-01 10.100.20.17:8092 check
```

Port 8092 is an external Docker port which goes to internal port 8090

comments: author: Administrator
body: you should't use docker


author: bdegier
body: Your dumb reply doesn't help anyone.


Tags: haproxy

nginx

proxy

synchrony