<Location /onlyoffice>
    Require all granted
    SetEnvIf Host "^(.*)$" THE_HOST=$1
    RequestHeader setifempty X-Forwarded-Proto https
    RequestHeader setifempty X-Forwarded-Host %{THE_HOST}e
    RequestHeader edit X-Forwarded-Host (.*) $1/onlyoffice
    ProxyAddHeaders Off
</Location>

RewriteEngine on
RewriteCond %{HTTP:Upgrade} websocket [NC]
RewriteCond %{HTTP:Connection} upgrade [NC]
RewriteRule ^\/onlyoffice/?(.*) "ws://127.0.0.1:8801/$1" [P,L]
ProxyPass /onlyoffice "http://127.0.0.1:8801"
ProxyPassReverse /onlyoffice "http://127.0.0.1:8801"
