Example: Collabora CODE

Collabora CODE (port from examples/collabora at master · caddyserver/examples · GitHub)

This is an example configuration of how to use Collabora CODE with caddy.

Collabora can then be used with, for example, NextCloud.

Note: In this example file Collabora CODE is started using its official docker container and reachable in the internal network using https://collabora:9980.

collabora.example.com {
  encode gzip

  @collabora {
    path /loleaflet/* # Loleaflet is the client part of LibreOffice Online
    path /hosting/discovery # WOPI discovery URL
    path /hosting/capabilities # Show capabilities as json
    path /lool/* # Main websocket, uploads/downloads, presentations
  }
  reverse_proxy @collabora https://collabora:9980 {
    transport http {
      tls_insecure_skip_verify
    }
  }
}

If you review posts #5 to #8 in this thread, it appears the named matcher is probably unnecessary and may even be cloaking some useful information. If you accept this, the Caddy block above reduces to:

collabora.example.com {
  encode gzip

  reverse_proxy https://collabora:9980 {
    transport http {
      tls_insecure_skip_verify
    }
  }
}

Furthermore, if your Collabora container is reachable on the internal network using http://collabora:9980, the Caddy block distills down even further to:

collabora.example.com {
  encode gzip

  reverse_proxy http://collabora:9980
}
2 Likes

@morph027 I drastically simplified the Caddyfile using Caddy v2’s named matchers in your post. Could you verify that it still works as intended?

Thanks for porting the example!

Jip, works. But why? According to the docs, named matchers are AND’ed …

The paragraph right below the one you read:

For most matchers that accept multiple values, those values are OR’ed; i.e. one must match in order for the matcher to match.

Since each of those are the same matcher (i.e. path) they get merged into one. I could just as easily put them all on one line, but I decided against it because I wanted to preserve the comments :+1:

In the example provided, if a path is not specified in the named matcher @collabora, for example, a request is made directly to collabora.example.com, does the reverse_proxy get skipped?

Yes, and Caddy will respond with an empty 200 response for any other paths. The matcher is probably altogether unnecessary here.

You’re right. I tested it without the matcher and it still works. Without the matcher, a request to collabora.example.com returns OK, which is actually quite useful feedback.

1 Like

(Feel free to update the wiki with your findings :grin:)

1 Like