Confluence cannot save edited document. Why?
Asked by Aleksey Nazimov:

Everything is fine. Unfortunately, I have the following error in my browser:

**WebSocket connection to 'ws://conf.numamo.net/synchrony-proxy/v1/bayeux-sync1' failed: Error during WebSocket handshake: Unexpected response code: 200**

My apache == apacheHouse 2.4.xx. It works perfectly except web sockets. My virtual host settings:

\<VirtualHost \*:80\>  
ServerName conf.numamo.net:80  
ProxyRequests Off

\<Proxy \*\>  
Require all granted  
\</Proxy\>

ProxyPass /synchrony <http://192.168.1.11:8072/synchrony>  
\<Location /synchrony\>  
Require all granted  
RewriteEngine on  
RewriteCond %{HTTP:UPGRADE} \^WebSocket$ \[NC\]  
RewriteCond %{HTTP:CONNECTION} Upgrade$ \[NC\]  
RewriteRule .\* ws://192.168.1.11:8072%{REQUEST_URI} \[P\]  
\</Location\>

ProxyPass "/" "<http://192.168.1.11:8072/>"  
ProxyPassReverse "/" "<http://192.168.1.11:8072/>"  
\<Location "/"\>  
Require all granted  
\</Location\>  

\</VirtualHost\>


Answers:
author: Aleksey Nazimov
body: Tested by experiments:

1) Downloading ApacheHouse 2.4

2) Making basic settings in the **httpd.conf** (<https://confluence.atlassian.com/kb/proxying-atlassian-server-applications-with-apache-http-server-mod_proxy_http-806032611.html?_ga=2.136404467.215557797.1549740003-711471428.1547848841>)

3) Setting virtual hosts in the **httpd-vhosts.conf**

*# Default virtual host!*   
*\<VirtualHost _default_:80\>*   
*DocumentRoot "${SRVROOT}/htdocs"*   
*\</VirtualHost\>*

*# Virtual host for "**xxx.numamo.net**"*   
*\<VirtualHost \*:80\>*   
*ServerName xxx.numamo.net:80*   
*ProxyRequests Off*

*\<Proxy \*\>*   
*Require all granted*   
*\</Proxy\>*

*ProxyPass /synchrony http://**InternalServerIp** :**8091**/synchrony*   
*\<Location /synchrony\>*   
*Require all granted*   
*RewriteEngine on*   
*RewriteCond %{HTTP:UPGRADE} \^WebSocket$ \[NC\]*   
*RewriteCond %{HTTP:CONNECTION} Upgrade$ \[NC\]*   
*RewriteRule .\* ws://**InternalServerIp** :**8091**%{REQUEST_URI} \[P\]*   
*\</Location\>*

*ProxyPass "/" "http://**InternalServerIp:HttpPort**/"*   
*ProxyPassReverse "/" "**http://InternalServerIp:HttpPort**/"*   
*\<Location "/"\>*   
*Require all granted*   
*\</Location\>*   

*ErrorLog "${SRVROOT}/logs/forConfluence/error.log"*   
*CustomLog "${SRVROOT}/logs/forConfluence/access.log" common*   
*\</VirtualHost\>*

*# Virtual host for redirecting to "xxx.numamo.net"*   
*\<VirtualHost \*:80\>*   
*ServerName [www.xxx.numamo.net:80](http://www.xxx.numamo.net:80)*   
*DocumentRoot "${SRVROOT}/htdocs/forConfluence"*   
*\<Directory "/"\>*   
*Require all granted*   
*\</Directory\>*   
*ErrorLog "${SRVROOT}/logs/forConfluence/error.log"*   
*CustomLog "${SRVROOT}/logs/forConfluence/access.log" common*   
*\</VirtualHost\>*

4) Setting confluence embedded Tomcat **server.xml**

*\<Connector port="HttpPort"*   
*maxThreads="150"*   
*minSpareThreads="25"*   
*connectionTimeout="20000"*   
*enableLookups="false"*   
*maxHttpHeaderSize="8192"*   
*protocol="HTTP/1.1"*   
*useBodyEncodingForURI="true"*   
*redirectPort="443"*   
*acceptCount="100"*   
*disableUploadTimeout="true"*   
*proxyName="xxx.numamo.net"*   
*proxyPort="80"*   
*scheme="http"*   
*relaxedPathChars="\[\]\|" relaxedQueryChars="\[\]\|{}\^\&#x5c;\&#x60;\&quot;\&lt;\&gt;"*   
*/\>*

*ATTENTION: "xxx.numamo.net" is the simplest example of my subdomain. "InternalServerIp" can be set by any address which is available for Apache-\>Tomcat connection. "HttpPort" can be set in the same way. Alternatively, If you don't have big problems with ConfluenceSynchrony then do not make any changes with the port # **8091**. This port is strongly fixed as a default*


author: Dave Theodore [Coyote Creek Consulting]
body: Which version of Confluence? I would recommend version 6.2 or newer, as these later versions allow Tomcat to proxy Synchrony and will save you this type of headache. Assuming you're on a modern version of Confluence later than 6.2 and not using Data Center, there is no need for any of this. Just proxy to Tomcat via 8090 per the [Atlassian docs](https://confluence.atlassian.com/kb/securing-your-atlassian-applications-with-apache-using-ssl-838284349.html).

comments: author: Aleksey Nazimov
body: **Thanks a lot!** I've corrected myself. I do not why, but It starts to work when all WS ports are set to 8091. See my corrections:

\<VirtualHost \*:80\>

....

ProxyPass /synchrony [http://192.168.1.11:8091/synchrony](http://192.168.1.11:8072/synchrony)  
\<Location /synchrony\>  
Require all granted  
RewriteEngine on  
RewriteCond %{HTTP:UPGRADE} \^WebSocket$ \[NC\]  
RewriteCond %{HTTP:CONNECTION} Upgrade$ \[NC\]  
RewriteRule .\* ws://192.168.1.11:8091%{REQUEST_URI} \[P\]  
\</Location\>

...

\</VirtualHost\>

According to the SYNCHRONY documents 8091 is a default value for the connected port.

**According to my practical experience (posted above), this default port cannot be changed by virtual host configurations.**


author: Dave Theodore [Coyote Creek Consulting]
body: Yes, Synchrony listens on 8091 by default. I'm glad you got it sorted out!


Tags: confluence-server

server