Documentserver: WebSokect over https sometimes get CORS failed

Created on 5 Jul 2020  路  9Comments  路  Source: ONLYOFFICE/DocumentServer

Do you want to request a feature or report a bug?

bug

What is the current behavior?

Access to XMLHttpRequest at 'wss://onlyoffice.host/cache/files/3513304646/Editor.bin/Editor.bin?md5=zwrJABWZTR3KNlN7oMBwAg&expires=1596534614&disposition=attachment&filename=Editor.bin' from origin 'https://onlyoffice.host' has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https.

https://stackoverflow.com/questions/62715140/why-cors-failed-at-wss-from-https-origin

If the current behavior is a bug, please provide the steps to reproduce and if possible a minimal demo of the problem.

Install nextcloud and onlyoffice behind https

What is the expected behavior?

Works

Did this work in previous versions of DocumentServer?

first to try DocumentServer

DocumentServer version:

5.5.3-39, use docker onlyoffice/documentserver:latest

Operating System:

server is linux
client is macos

Browser version:

Google Chrome is up to date
Version 83.0.4103.116 (Official Build) (64-bit)

help wanted

Most helpful comment

Hello @wenerme, sorry for the late reply.
Onlyoffice-documentserver needs X-Forwarded-Proto as http(s) header. You need to edit labels in your traefik config for onlyoffice-documentserver container, for exsample:

...
    labels:
      ...
      - "traefik.http.routers.<your_name>.middlewares=onlyoffice-headers"
      - "traefik.http.middlewares.onlyoffice-headers.headers.customrequestheaders.X-Forwarded-Proto=https"
      - "traefik.http.middlewares.onlyoffice-headers.headers.accessControlAllowOrigin=*"

All 9 comments

I have the exact same issue. I'm using Traefik v2.2 as a reverse proxy

I use traefik too, 2.2.1, does this related to traefik ?

Not easy to switch, use traefik ingress.

Just a note - I've never seen such an error but never used traefik, so I think this may related. But since I have no experience with it - I'm not sure I can help without detailed steps to reproduce this problem

I will setup a new cluster using haproxy as ingress, check is this still exists.

New deployed cluster use ingress-nginx is working, I also switched the old cluster from traefik to ingress-nginx, now working. The problem is related to traefik.

Hello @wenerme, sorry for the late reply.
Onlyoffice-documentserver needs X-Forwarded-Proto as http(s) header. You need to edit labels in your traefik config for onlyoffice-documentserver container, for exsample:

...
    labels:
      ...
      - "traefik.http.routers.<your_name>.middlewares=onlyoffice-headers"
      - "traefik.http.middlewares.onlyoffice-headers.headers.customrequestheaders.X-Forwarded-Proto=https"
      - "traefik.http.middlewares.onlyoffice-headers.headers.accessControlAllowOrigin=*"

@igwyd Thanks, but I can't verify this, I think this can be closed now.

Hi @wenerme
I can verify. This fix works on my side with traefik v2.2

@jacksitlab Thanks, close now.

Was this page helpful?
0 / 5 - 0 ratings