Skip to content

Instantly share code, notes, and snippets.

@julianpoemp
Last active February 12, 2026 07:45
Show Gist options
  • Select an option

  • Save julianpoemp/2d4db46a042ff2c5fe431671c0c7afa4 to your computer and use it in GitHub Desktop.

Select an option

Save julianpoemp/2d4db46a042ff2c5fe431671c0c7afa4 to your computer and use it in GitHub Desktop.
This gist shares an easy workaround that resolves the domain of a standalone Callabora Office server and saves the IP address to the wopi allowlist.

How to resolve domain to IP address for Collabora Office server with dynamic IP for nextcloud office

Problem

If you install your own Collabora Office server on your home server and your public IP address changes from time to time (dynamic IP address) you'll find an issue: Your nextcloud ist blocking requests to the office server because the IP of the wopi allow list does not match that one from your server. For now you are not able to set a domain to the wopi allow list directly in nextcloud settings.

Solution

A PHP script resolves the domain of your Collabora Office server to an IP address and sets the new IP address to the wopi allowlist of your nextcloud instance. Simple! :)

Installation

  1. Download the ip-resolution.php and set the variables for your nextcloud instance.
  2. Upload the ip-resolution.php to your web server. Don't copy it to your owncloud server, it would make updating nextcloud fail.
  3. Open the URL to the ip-resolution.php in your browser. No errors should be visible.
  4. If everything is fine, in the ip-resolution.php set $DEBUG to false.
  5. Set a cronjob that runs the ip-resolution.php e.g. each 15 minutes.

That's all! If you like this gist, I'd be happy if you give it a star :)

<?php
// Version: 1.0.0
// Author: Julian Poemp
// Get latest version here: https://gist.github.com/julianpoemp/2d4db46a042ff2c5fe431671c0c7afa4
$DEBUG = true;
$DOMAIN = "www."; // must start with www.; Domain to your Callabora office server
$DB_HOST = "localhost"; // keep it to localhost if on same machine
$DB_PORT = 3306;
$DB_NAME = "";
$DB_USER = "";
$DB_PASSWORD = "";
if ($DEBUG) {
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
}
$new_ip = gethostbyname($DOMAIN);
$mysqli = new mysqli($DB_HOST, $DB_USER, $DB_PASSWORD, $DB_NAME, $DB_PORT);
if (!$mysqli) {
die("Database connection failed: " . mysqli_connect_error());
}
$result = $mysqli->query("SELECT appid, configkey, configvalue FROM oc_appconfig WHERE appid = 'richdocuments' AND configkey = 'wopi_allowlist'");
if (!$result) {
$mysqli->close();
die("Can't find oc_appconfig entry for wopi_allowlist.");
}
$row = $result->fetch_assoc();
$old_ip = $row["configvalue"];
$result = $mysqli->query("UPDATE oc_appconfig SET configvalue = '$new_ip/24' WHERE appid = 'richdocuments' AND configkey = 'wopi_allowlist'");
if (!$result) {
$mysqli->close();
die("Can't update oc_appconfig entry for wopi_allowlist.");
}
$mysqli->close();
if ($DEBUG) {
echo "Changed ip from <b>$old_ip</b> to <b>$new_ip/24</b>";
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment