Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issues with HTTP Status Moved (Permanently) HTTP 301 Nextcloud, Collabora & Nginx Reverse Proxies #11287

Open
ksaadDE opened this issue Mar 6, 2025 · 5 comments
Assignees
Labels
24.04 bug Something isn't working unconfirmed

Comments

@ksaadDE
Copy link

ksaadDE commented Mar 6, 2025

Describe the Bug

When having everything properly configured (including nextcloud), the collabora system tries to grab the preset from an url, when opening a document in nextcloud.

If the preset pull response status is 301 (HTTP STATUS 301 / PERMANENTLY MOVED) e.g. due to one or multiple nginx reverse proxies, it will automatically break and report failure.

Steps to Reproduce

  1. Install nextcloud latest & collabora/code latest via docker (configure everything, including the nginx reverse proxies etc)
  2. Go in the nextcloud and load a document (.odt)
  3. docker logs collabora (shows the Failed to get settings json from [http://http_nextcloud.domain/index.php/apps/richdocuments/wopi/settings?type=systemconfig&access_token=xxxxx&fileId=-1] with status[Moved Permanently]|wsd/DocumentBroker.cpp:1820)
  4. Install older tag e.g. collabora/code:24.04.10.1.1 (this one shall work)

Expected Behavior

Installation just loads and allows editing of the documents via nextcloud using collabora/code container behind nginx reverse proxies

Actual Behavior

The loading of the preset fails, due to Permanently Moved, as only HTTP STATUS OK is being checked for, thus the whole execution is aborted. See suggested patch below.

Additional Context

please read 3ed4b49#r153381554

Not sure if this belongs to online but it has the bug in the same code base so

@ksaadDE
Copy link
Author

ksaadDE commented Mar 6, 2025

@Rash419

@ksaadDE
Copy link
Author

ksaadDE commented Mar 6, 2025

Short summary of the troublesome line as mentioned in the commit & commentary: 3ed4b49#r153381554

if (presetHttpResponse->statusLine().statusCode() != http::StatusCode::OK) 
{
// ...
}

The required patch could be:

if (presetHttpResponse->statusLine().statusCode() != http::StatusCode::OK && 
presetHttpResponse->statusLine().statusCode() != http::StatusCode::MovedPermanently) 
{
//...
}

Surely, there is a more smart and dynamic alternative (C++ is not my main business) to exclude various HTTP codes that shall not negatively affect the continuation of the processing!

I found the statusCode enum in https://github.com/CollaboraOnline/online/blob/3ed4b490fc84868c6dab7a2aa62eac6b3182286d/net/HttpRequest.hpp

As the containers of two months ago are working fine with fixed version. Just the latest tag breaks.

@ksaadDE ksaadDE changed the title Issues with HTTP Status Moved (Permanently) HTTP 301 and Nextcloud Issues with HTTP Status Moved (Permanently) HTTP 301 Nextcloud, Collaora & Nginx Reverse Proxies Mar 6, 2025
ksaadDE referenced this issue Mar 6, 2025
Signed-off-by: Rashesh <[email protected]>
Change-Id: Id8510d9893a2dfb9eb3ece67bf7374e44085856d
@ksaadDE ksaadDE changed the title Issues with HTTP Status Moved (Permanently) HTTP 301 Nextcloud, Collaora & Nginx Reverse Proxies Issues with HTTP Status Moved (Permanently) HTTP 301 Nextcloud, Collabora & Nginx Reverse Proxies Mar 6, 2025
@Rash419
Copy link
Contributor

Rash419 commented Mar 7, 2025

Thank you for the report. I will check in few hours 🙂

@Rash419 Rash419 self-assigned this Mar 7, 2025
@Rash419
Copy link
Contributor

Rash419 commented Mar 7, 2025

@ksaadDE Hey, can you share your nginx config ?

@Rash419
Copy link
Contributor

Rash419 commented Mar 7, 2025

I tried reproducing the problem with following nginx config and docker compose, but no luck :(

nginx.conf

worker_processes 1;
events {
    worker_connections 1024;
}

http {
    server {
        listen 80;

        # Proxy for Nextcloud
        server_name nextcloud.local;
        location / {
            proxy_pass http://nextcloud:80;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
            proxy_set_header X-Forwarded-Proto $scheme;
        }
    }

    server {
        listen 80;

        # Proxy for Collabora Online
        server_name collabora.local;

        # static files
        location ^~ /browser {
          proxy_pass http://collabora:9980;
          proxy_set_header Host $host;
        }


        # WOPI discovery URL
        location ^~ /hosting/discovery {
          proxy_pass http://collabora:9980;
          proxy_set_header Host $host;
        }


        # Capabilities
        location ^~ /hosting/capabilities {
          proxy_pass http://collabora:9980;
          proxy_set_header Host $host;
        }


        # main websocket
        location ~ ^/cool/(.*)/ws$ {
          proxy_pass http://collabora:9980;
          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 ~ ^/(c|l)ool {
          proxy_pass http://collabora:9980;
          proxy_set_header Host $host;
        }


        # Admin Console websocket
        location ^~ /cool/adminws {
          proxy_pass http://collabora:9980;
          proxy_set_header Upgrade $http_upgrade;
          proxy_set_header Connection "Upgrade";
          proxy_set_header Host $host;
          proxy_read_timeout 36000s;
        }

        location / {
            proxy_pass http://collabora:9980;
            proxy_set_header Host $host;
        }
    }
}

docker-compose.yml:

version: '3.8'

services:
  # Nginx Reverse Proxy
  nginx:
    image: nginx:latest
    container_name: nginx
    restart: always
    ports:
      - "80:80"
    volumes:
      - ./nginx/nginx.conf:/etc/nginx/nginx.conf:ro
    depends_on:
      - nextcloud
      - collabora

  # Nextcloud
  nextcloud:
    image: nextcloud:latest
    container_name: nextcloud
    restart: always
    environment:
      - NEXTCLOUD_ADMIN_USER=admin
      - NEXTCLOUD_ADMIN_PASSWORD=admin
    volumes:
      - ./nextcloud/data:/var/www/html
    extra_hosts:
      - "collabora.local:192.168.1.12"

  # Collabora Online (CODE)
  collabora:
    image: collabora/code:latest
    container_name: collabora
    restart: always
    environment:
      - aliasgroup1=http://nextcloud.local
      - extra_params=--o:ssl.enable=false --o:logging.level=information
      - username=admin
      - password=admin
    extra_hosts:
      - "nextcloud.local:192.168.1.12"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
24.04 bug Something isn't working unconfirmed
Projects
Status: No status
Development

No branches or pull requests

2 participants