404 error behind virtual path proxy for some URL (web-apps)

Hi,

I’m trying to configure an ONLYOFFICE Docs instance behind a proxy with a virtual path.
Everything worked good and I managed to run the example front page, but I cannot edit any document: there is a 404 error when calling the file api.js as the virtual path is not correctly set.

The proxy is an Apache HTTP server. I followed the example here:

And I ended up with the following, more or less a copy-paste from the doc:

(...)
Define VPATH /onlyoffice
Define DS_ADDRESS localhost:81

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

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

But while pretty much everything is correctly redirected to /onlyoffice, it is not the case for api.js.

The called URL is site.tld/web-apps/apps/api/documents/api.js, which is wrong.
It should be site.tld/onlyoffice/web-apps/apps/api/documents/api.js.

Any idea on the issue? Thanks in advance for your insights.

I made a slight change since the proxy is in HTTPS, according to:

The change is using RequestHeader setifempty X-Forwarded-Proto https instead of http, but nothing changed.

Update: while the ds-example doesn’t work, the integration to NextCloud did with the last change (https instead of http). Weird. Maybe just an issue with the example?

Anyway, it works for the main product now so it’s okay.

Hello @dany.jupille
By default, the built-in integration example does not work with a proxy. This was the reason for the incorrect operation.

I see, thanks for the explanations.

1 Like