opened 04:32PM - 31 Oct 24 UTC
closed 11:12AM - 01 Nov 24 UTC
bug
unconfirmed
### Describe the Bug
I'm trying to run Collabora on a docker container behind a… Nginx reverse proxy with a specific URL suffix.
The goal for now is to show a document on a web-page using Collabora. To achieve this I've followed the [Step by step tutorial](https://sdk.collaboraonline.com/docs/Step_by_step_tutorial.html) guide and I'm using Flask to build my WOPI host with a simple "Hello world" example.
My setup works great without the URL suffix (example: https://mydomain.com) although, since I'm already serving my web-application on the root URL I've the need to have Collabora available with the suffix "/collabora/" (i.e., https://mydomain.com/collabora/). When using the suffix I end up with the following error:
`collabora-app | wsd-00001-00036 2024-10-08 15:05:51.056804 +0000 [ websrv_poll ] ERR #31: #31 Exception while processing incoming request: [GET /collabora/cool/https:/mydomain.com/flask/wopi/files/1233%3Faccess_token=test&access_token_ttl=0/ws?WOPISrc=https%3A%2F%2Fmydomain.com%2Fflask%2Fwopi%2Ffiles%2F12...]: Bad URI syntax| wsd/ClientRequestDispatcher.cpp:915`
### Steps to Reproduce
I’m running Collabora on a docker container with the following compose.yml:
```
services:
collabora-app:
image: collabora/code
container_name: collabora-app
ports:
- "127.0.0.1:8085:9980"
environment:
- domain=mydomain.com
- extra_params=--o:ssl.enable=false --o:hostname=mydomain.com --o:ssl.termination=true
- aliasgroup1=https://mydomain.com
extra_hosts:
- "mydomain.com:host-gateway"
```
My Flask application will be running locally on port 5000.
My host is a VM with hostname **mydomain.com** (where its DNS have also the same name - **mydomain.com**). Since I’m running my VM on the internet I’m only exposing port 443 and I’m using Nginx as a reverse proxy.
Also, on my VM, **mydomain.com** is mapped to **127.0.0.1**, i.e., in my VM **/etc/hosts** I have:
**127.0.0.1 mydomain.com**
My correspondent Nginx conf is:
```
location /flask/ {
proxy_set_header X-Forwarded-Host $host:$server_port;
proxy_set_header X-Forwarded-Server $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://127.0.0.1:5000/;
}
location ^~ /browser {
proxy_pass http://127.0.0.1:8085;
proxy_set_header Host $host;
}
location ^~ /hosting/discovery {
proxy_pass http://127.0.0.1:8085;
proxy_set_header Host $host;
}
location ^~ /hosting/capabilities {
proxy_pass http://127.0.0.1:8085;
proxy_set_header Host $host;
}
location ~ ^/cool/(.*)/ws$ {
proxy_pass http://127.0.0.1:8085;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_read_timeout 36000s;
}
location ~ ^/(c|l)ool {
proxy_pass http://127.0.0.1:8085;
proxy_set_header Host $host;
}
location ^~ /cool/adminws {
proxy_pass http://127.0.0.1:8085;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_read_timeout 36000s;
}
location / {
proxy_pass http://127.0.0.1:8085/;
proxy_set_header Host $host;
proxy_buffering off;
}
```
**with this setup everything works just fine!**
Now, using the "/collabora/" as URL suffix, my nginx.conf is the following:
```
# static files
location ^~ /collabora/browser {
proxy_pass http://127.0.0.1:8085/browser;
proxy_set_header Host $host;
}
# WOPI discovery URL
location ^~ /collabora/hosting/discovery {
proxy_pass http://127.0.0.1:8085/hosting/discovery;
proxy_set_header Host $host;
}
# Capabilities
location ^~ /collabora/hosting/capabilities {
proxy_pass http://127.0.0.1:8085/hosting/capabilities;
proxy_set_header Host $host;
}
# main websocket
location ~ ^/collabora/cool/(.*)/ws$ {
proxy_pass http://127.0.0.1:8085/cool/$1/ws;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_read_timeout 36000s;
}
# download, presentation and image upload
location ~ ^/collabora/(c|l)ool {
proxy_pass http://127.0.0.1:8085/$1ool;
proxy_set_header Host $host;
}
# Admin Console websocket
location ^~ /collabora/cool/adminws {
proxy_pass http://127.0.0.1:8085/cool/adminws;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_read_timeout 36000s;
}
location /collabora/ {
proxy_pass http://127.0.0.1:8085/;
proxy_set_header Host $host;
proxy_buffering off;
}
```
With this change I quickly realize that the “urlsrc” links (from "/hosting/discovery") wouldn’t reflect my change, since they were still pointing to the standard source:
**https://mydomain.com/browser/d5ebff5/cool.html?**
instead of:
**https://mydomain.com/collabora/browser/d5ebff5/cool.html?**
Which leads my to several 404 not found errors.
After some searching i’ve found out the need to include **--o:net.service_root=/collabora** on my docker setup in order to reflect the change of having the suffix. Accordingly I changed my **compose.yml** to:
```
services:
collabora-app:
image: collabora/code
container_name: collabora-app
ports:
- "127.0.0.1:8085:9980"
environment:
- domain=mydomain.com
- extra_params=--o:ssl.enable=false --o:hostname=mydomain.com --o:ssl.termination=true --o:net.service_root=/collabora --o:server_name=mydomain.com
- aliasgroup1=https://mydomain.com
extra_hosts:
- "mydomain.com:host-gateway"
```
This change makes Collabora accessible (locally in the host) through 127.0.0.1:8085/collabora/
Accordingly, I changed Nginx conf file as well:
```
location ^~ /collabora/browser {
proxy_pass http://127.0.0.1:8085/collabora/browser;
proxy_set_header Host $host;
}
location ^~ /collabora/hosting/discovery {
proxy_pass http://127.0.0.1:8085/collabora/hosting/discovery;
proxy_set_header Host $host;
}
location ^~ /collabora/hosting/capabilities {
proxy_pass http://127.0.0.1:8085/collabora/hosting/capabilities;
proxy_set_header Host $host;
}
location ~ ^/collabora/cool/(.*)/ws$ {
proxy_pass http://127.0.0.1:8085/collabora/cool/$1/ws;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_read_timeout 36000s;
}
location ~ ^/collabora/(c|l)ool {
proxy_pass http://127.0.0.1:8085/collabora/$1ool;
proxy_set_header Host $host;
}
location ^~ /collabora/cool/adminws {
proxy_pass http://127.0.0.1:8085/collabora/cool/adminws;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_read_timeout 36000s;
}
location /collabora/ {
proxy_pass http://127.0.0.1:8085/collabora/;
proxy_set_header Host $host;
proxy_buffering off;
}
```
With this change, all the urls seem to have the “right link”, i.e, in **https://mydomain.com/collabora/hosting/discovery** we can see now the “correct” urlsrc values.
Now, when I try to run the very same example I end up with:
`WebSocket connection to 'wss://mydomain.com/collabora/cool/https%3A%2F%2Fmydomain.com%2Fflask%2Fwopi%2Ffiles%2F1233%3Faccess_token%3Dtest%26access_token_ttl%3D0/ws?WOPISrc=https%3A%2F%2Fmydomain.com%2Fflask%2Fwopi%2Ffiles%2F1233&compat=/ws' failed: Error during WebSocket handshake: Unexpected response code: 400`
Checking/inspecting the websocket call the request URL I have:
`wss://mydomain.com/collabora/cool/https%3A%2F%2Fmydomain.com%2Fflask%2Fwopi%2Ffiles%2F1233%3Faccess_token%3Dtest%26access_token_ttl%3D0/ws?WOPISrc=https%3A%2F%2Fmydomain.com%2Fflask%2Fwopi%2Ffiles%2F1233&compat=/ws`
From Collabora docker logs I have:
`collabora-app | wsd-00001-00036 2024-10-08 15:05:51.056804 +0000 [ websrv_poll ] ERR #31: #31 Exception while processing incoming request: [GET /collabora/cool/https:/mydomain.com/flask/wopi/files/1233%3Faccess_token=test&access_token_ttl=0/ws?WOPISrc=https%3A%2F%2Fmydomain.com%2Fflask%2Fwopi%2Ffiles%2F12...]: Bad URI syntax| wsd/ClientRequestDispatcher.cpp:915`
Double checking the URL that is being used in the POST request, directly from my test application:
**https://mydomain.com/collabora/browser/d5ebff5/cool.html?WOPISrc=https%3A%2F%2Fmydomain.com%2Fflask%2Fwopi%2Ffiles%2F123**
Where we can access to both:
**https://mydomain.com/collabora/browser/d5ebff5/cool.html?**
and
**https://mydomain.com/flask/wopi/files/123**
Checking Nginx logs we can confirm the the URL POST request:
```
xxx.xx.xxx.xxx - - [09/Oct/2024:05:30:24 -0400] "POST /collabora/browser/d5ebff5/cool.html?WOPISrc=https%3A%2F%2Fmydomain.com%2Fflask%2Fwopi%2Ffiles%2F123
HTTP/2.0" 200 3695 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
```
Then we can see the following GET requests (to the POST) in Nginx logs:
```
xxx.xx.xxx.xxx - - [09/Oct/2024:05:30:24 -0400] "GET /collabora/browser/d5ebff5/branding.js HTTP/2.0" 200 1089 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
xxx.xx.xxx.xxx - - [09/Oct/2024:05:30:24 -0400] "GET /collabora/browser/d5ebff5/branding.css HTTP/2.0" 200 6699 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
xxx.xx.xxx.xxx - - [09/Oct/2024:05:30:24 -0400] "GET /collabora/browser/d5ebff5/global.js HTTP/2.0" 200 10121 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
xxx.xx.xxx.xxx - - [09/Oct/2024:05:30:24 -0400] "GET /collabora/browser/d5ebff5/bundle.css HTTP/2.0" 200 114261 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
xxx.xx.xxx.xxx - - [09/Oct/2024:05:30:24 -0400] "GET /collabora/browser/d5ebff5/bundle.js HTTP/2.0" 200 782266 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
xxx.xx.xxx.xxx - - [09/Oct/2024:05:30:24 -0400] "GET /collabora/browser/d5ebff5/device-desktop.css HTTP/2.0" 200 302 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
xxx.xx.xxx.xxx - - [09/Oct/2024:05:30:24 -0400] "GET /collabora/browser/d5ebff5/branding-desktop.css HTTP/2.0" 200 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
xxx.xx.xxx.xxx - - [09/Oct/2024:05:30:24 -0400] "GET /collabora/browser/d5ebff5/images/closedoc.svg HTTP/2.0" 200 310 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
xxx.xx.xxx.xxx - - [09/Oct/2024:05:30:24 -0400] "GET /collabora/cool/https%3A%2F%2Fmydomain.com%2Fflask%2Fwopi%2Ffiles%2F123%3Faccess_token%3Dtest%26access_token_ttl%3D0/ws?WOPISrc=https%3A%2F%2Fmydomain.com%2Fflask%2Fwopi%2Ffiles%2F123&compat=/ws HTTP/1.1" 400 0 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36
```
Where this last GET request, with the 400 errror, corresponds to what we then see on Collabora logs:
`collabora-app | wsd-00001-00036 2024-10-09 09:30:24.907091 +0000 [ websrv_poll ] ERR #31: #31 Exception while processing incoming request: [GET /collabora/cool/https:/mydomain.com/flask/wopi/files/123%3Faccess_token=test&access_token_ttl=0/ws?WOPISrc=https%3A%2F%2Fmydomain.com%2Fflask%2Fwopi%2Ffiles%2F123...]: Bad URI syntax| wsd/ClientRequestDispatcher.cpp:915`
Also, I noticed when I use Collabora withing the root URL path (https://mydomain.com/) - where I manage to have it working - I can see from my Nginx logs the following calls:
```
xxx.xx.xxx.xxx - - [09/Oct/2024:12:28:18 -0400] "POST /browser/d5ebff5/cool.html?WOPISrc=https%3A%2F%2Fmydomain.com%2Fflask%2Fwopi%2Ffiles%2F123 HTTP/2.0"
200 3680 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:131.0) Gecko/20100101 Firefox/131.0"
172.19.0.2 - - [09/Oct/2024:12:28:18 -0400] "GET /flask/wopi/files/123?access_token=test&access_token_ttl=0 HTTP/1.1" 200 222 "-" "COOLWSD HTTP Agent 24.04.7.2"
xxx.xx.xxx.xxx - - [09/Oct/2024:12:28:18 -0400] "GET /browser/d5ebff5/branding.css HTTP/2.0" 200 6699 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:131.0) Gecko/201
00101 Firefox/131.0"
xxx.xx.xxx.xxx - - [09/Oct/2024:12:28:18 -0400] "GET /browser/d5ebff5/bundle.css HTTP/2.0" 200 114261 "-" "Mozilla/5.0 (X11; Linux x86_64; rv:131.0) Gecko/201
00101 Firefox/131.0"
```
We can see the POST request from my application and right after we can see a GET request coming from docker (172.19.0.2) to my application WOPI interface.
Now when we use the prefix on the URL for collabora (https://mydomain.com/collabora/) I noticed that only the POST is made on Nginx but we dont get the GET request from docker:
```
xxx.xx.xxx.xxx - - [09/Oct/2024:12:35:58 -0400] "POST /collabora/browser/d5ebff5/cool.html?WOPISrc=https%3A%2F%2Fmydomain.com%2Fflask%2Fwopi%2Ffiles%2F123 HTTP/2.0" 200 3695 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
xxx.xx.xxx.xxx - - [09/Oct/2024:12:35:58 -0400] "GET /collabora/browser/d5ebff5/branding.css HTTP/2.0" 200 6699 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
xxx.xx.xxx.xxx - - [09/Oct/2024:12:35:58 -0400] "GET /collabora/browser/d5ebff5/branding.js HTTP/2.0" 200 1089 "-" "Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/129.0.0.0 Safari/537.36"
```
After some more playing with Nginx conf file I believe the issue may be on this rule?
```
location ~ ^/collabora/cool/(.*)/ws$ {
proxy_pass http://127.0.0.1:8085/collabora/cool/$1/ws;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_read_timeout 36000s;
}
```
With this rule in place, we cannot observe the call:
**172.19.0.2 - - [09/Oct/2024:12:28:18 -0400] "GET /flask/wopi/files/123?access_token=test&access_token_ttl=0 HTTP/1.1" 200 222 "-" "COOLWSD HTTP Agent 24.04.7.2"**
Making the change to (removing /collabora/ from the proxy_pass parameter):
```
location ~ ^/collabora/cool/(.*)/ws$ {
rewrite ^/collabora/cool/(.*)/ws$ /$1/ws break;
proxy_pass http://127.0.0.1:8085/cool/$1/ws;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "Upgrade";
proxy_set_header Host $host;
proxy_read_timeout 36000s;
}
```
we can see the GET call being made! Although, as expected, collabora logs complain about:
**collabora-app | wsd-00001-00036 2024-10-10 08:23:10.825828 +0000 [ websrv_poll ] ERR #33: #33 bad request: [GET /cool/https:/mydomain.com/flask/wopi/fil...]: The request does not start with prefix: /collabora| wsd/ClientRequestDispatcher.cpp:905**
### Expected Behavior
Using a suffix on the URL collabora should be able to handle it
### Actual Behavior
Not working under an URL with a suffix
### Desktop
- **Collabora version:** latest docker version
- **OS and version:** Debian 11
- **Browser and version:** Chromium 130.0.6723.69
### Additional Context
Before opening this issue I have opened a tread on [Collabora forum](https://forum.collaboraonline.com/t/possible-nginx-reverse-proxy-issue-bad-uri-syntax-wsd-clientrequestdispatcher-cpp/3049/11)
Much likely this can be due to an issue with my setup, although I've been playing around with it for some time now without any success on fixing it.