Correct nginx proxy pass config

Hey,
I want to install the latest collabora for my Nextcloud 11.0.2 with nginx proxypass. And found two install guides both not working -.-

Link From Nextcloud: https://icewind.nl/entry/collabora-online/
And the latest from collabora: Collabora Online Development Edition (CODE) - Collabora Office and Collabora Online

The one from collabora seems to be promising and It all seems to be fine: https://office.domain.tld/hosting/discovery returns:

But Nextcloud returns:
Well, this is embarrassing, we cannot connect to your document. Please try again.

Collabrora Serverlog:
loolforkit version details: 2.0.4 - 2.0.4
office version details: { ā€œProductNameā€: ā€œCollabora Officeā€, ā€œProductVersionā€: ā€œ5.1ā€, ā€œProductExtensionā€: ā€œ.10.21ā€, ā€œBuildIdā€: ā€œe91d2c2d59b035e40bdefac5fe06fb210180ed86ā€ }
wsd-00025-0028 09:26:54.835450 [ client_req_hdl ] WRN WOPI host did not pass optional access_token_ttl| wsd/FileServer.cpp:255
wsd-00025-0026 09:26:55.144542 [ client_ws_0002 ] ERR ClientRequestHandler::handleClientRequest: BadRequestException: Invalid or unknown request.| wsd/LOOLWSD.cpp:1240

So it seems to be a nginx problem?! Is even someone running nginx/nextcloud at the latests versions without problems?

Thanks for help :slight_smile:

I run NC and CODE in different VMS with an NGINX proxy on the Frontend (and CODE has a different domain):
so this config may be wrong for you but may give you a hint:

server {
    listen               443 ssl http2;
    server_name          office.xxx;
    ssl_certificate      /etc/letsencrypt/live/office.xxxx/fullchain.pem;
    ssl_certificate_key  /etc/letsencrypt/live/office.xxx/privkey.pem;
    client_max_body_size 10G;
    proxy_set_header     X-Forwarded-Proto 'https';
    underscores_in_headers on;
    add_header           Strict-Transport-Security "max-age=31536000";

    location /.well-known/ {
        root   /var/lib/nginx/letsencrypt/;
        index  index.html index.htm;
    }

    # static files
    location ^~ /loleaflet {
        proxy_pass        https://1.2.3.4:9980;
        proxy_set_header Host $http_host;
        proxy_ssl_verify              off;
    }

    # WOPI discovery URL
    location ^~ /hosting/discovery {
        proxy_pass        https://1.2.3.4:9980;
        proxy_set_header Host $http_host;
        proxy_ssl_verify              off;
        
        # WebSocket support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

    # Main websocket
    location ~ /lool/(.*)/ws$ {
        proxy_pass        https://1.2.3.4:9980;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $http_host;
        proxy_read_timeout 36000s;
        proxy_ssl_verify              off;
        # WebSocket support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

    }

    # Admin Console websocket
    location ^~ /lool/adminws {
        proxy_pass        https://1.2.3.4:9980;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $http_host;
        proxy_read_timeout 36000s;
        proxy_ssl_verify              off;
        # WebSocket support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

    }

    # download, presentation and image upload
    location ^~ /lool {
        proxy_pass        https://1.2.3.4:9980;
        proxy_set_header Host $http_host;
        proxy_ssl_verify              off;
        # WebSocket support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";

    }

    location / {
        proxy_pass        https://1.2.3.4:9980;
        proxy_set_header Host $http_host;
        proxy_ssl_verify              off;

        # WebSocket support
        proxy_http_version 1.1;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "upgrade";
    }

}

Also, just enter ā€˜https://office.domainā€™ in the NC Config, if you add a trailing ā€˜/ā€™ it will break

thanks for you answer. I will try this. What do you mean by ā€œAlso, just enter ā€˜https://office.domainā€™ in the NC Config, if you add a trailing ā€˜/ā€™ it will breakā€ I didnt change the NC config for collabora at all. I only set the url at the NC App. Their is nothing at the tutorials. Did I miss something?

Thats what i meant

Ok thanks. I get no more errors at the logs and https://office.cloud13.de/hosting/discovery works also fine with your nginx configā€¦ but still:

Well, this is embarrassing, we cannot connect to your document. Please try again.

this msg when I try to open a document. Serverlogs are as follow:

Thanks for help

Hey I had the same problem with nginx and nextcloud. I solved by changing
location ^~ /lool
into
location ~ /lool

I found that somewhere else here on the forums after scratching my head for several hours.
Still donā€™t know exactly what the problem was, but it had to do with the url links that nginx passes along.

Thanks for your answer. I tried this as well and removed the ā€œ^ā€ but with no success. Nothing changedā€¦ Can you please post you nginx config. thanks :slight_smile:

Here it is. I think the upstream part is also important for letting nginx pass the uri unchanged (no url decode)

upstream collada-office {
    server 127.0.0.1:9980;
}

server {
    listen 443 ssl;
    server_name office.example.com;
 
    ssl_certificate /etc/letsencrypt/live/office.example.com/fullchain.pem;
    ssl_certificate_key /etc/letsencrypt/live/office.example.com/privkey.pem;

    # static files
    location ^~ /loleaflet {
        proxy_pass https://collada-office;
        proxy_set_header Host $host;
    }

    # WOPI discovery URL
    location ^~ /hosting/discovery {
        proxy_pass https://collada-office;
        proxy_set_header Host $host;
    }

    # Main websocket
    location ~ /lool/(.*)/ws$ {
        proxy_pass https://collada-office;
        proxy_set_header Upgrade $http_upgrade;
        proxy_set_header Connection "Upgrade";
        proxy_set_header Host $host;
        proxy_read_timeout 36000s;
    }

    # Admin Console websocket
    location ^~ /lool/adminws {
	proxy_buffering off;
        proxy_pass https://collada-office;
        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 ~ /lool {
        proxy_pass https://collada-office;
        proxy_set_header Host $host;
    }
}
2 Likes

Thanks for you help! But still not working for me :frowning:

In my setup I have an nginx container and the office containerā€¦ both on the same host and network. Could this be a reason? Im always changing the ā€œ127.0.0.1ā€ to ā€œcontainernameā€ and I getting no errors and see the connections in the logs.

@rtznprmpftl Did you change some settings in the office container (or somewhere else than the nginx config) when you run it on 2 different servers?

Ok I found out that the config from @scryver is working. But I have encryption enabledā€¦ Thanks for your help guys! I will try onlyoffice next :wink:

Finally I got my CODE installation working, too, thanks to the config scryver provided.

Request to mods: Could we make this sticky please? I donā€™t know how many threads exist in order to get CODE working with Nginxā€¦

I recommend to check if several people get that working and then do a pull request on github for the homepage, add a nginx section.

My setup is the same as cracker0dks. Cloud and CODE in separate Containers on one docker-installation with only one domain and separat certs for each host-container. The nginxproxy ist jwilder/nginx-proxy with jrcs/letsencrypt-nginx-proxy-companion. All seems to be ok, but:

cURL error 7: Failed to connect to office.mydomain.de port 443: Connection refused

Where must I insert the solution in this nginx-config? In /etc/nginx/vhost.d? My changes in /etc/nginx/vhost.d will overwrite on next startup. Must I change the name ā€œcollada-officeā€ to my container-names?

you dont have to name it ā€œcollada-office" but it must be consistent with your nginx config part.
ā€œConnection refusedā€ seems to be a nginx config problem.

I changed the default.conf on my nginx (nothing else). Dont forget to reload nginx to reload the changed config.

Thanks for the quick answer. In my case with jwilder/nginx-proxy will the configfile /etc/nginx/conf.d/default.conf rewrite with dynamic content in dependence of the started client-containers. The format of this file is equal to yours. The file /etc/nginx/vhost.d/default is static and can be editing persistent. Server-statements are not allowed.

Do you know which kinds of possibilitys I have?

scryver, that config worked! I been trying to figure this out for months. Thank you!!