Changing Owncloud external URL

Hello all, I’ve been testing Owncloud using the ESX VM appliance downloaded from their site, updated to Univention 4.4.2 errata 350 + docker container for Owncloud 10.2.1.1 (and another one for Redis).

After some struggle I’ve been able to integrate the Univention appliance with our internal AD domain, and now have a working Owncloud setup, with a non standard URL, /cloud instead of /owncloud.

In order to have the URL working, I had to manually edit (at host level) /etc/apache2/sites-enabled/000-default.conf and /etc/apache2/sites-enabled/defalt-ssl.conf so that the Apache reverse proxy can correctly process requests to my.domain.name/cloud and forward them to the Owncloud container. In other words, I manually edited the directives within whose files from

ProxyPass /owncloud http://127.0.0.1:40001/owncloud retry=0
ProxyPassReverse /owncloud http://127.0.0.1:40001/owncloud

to

ProxyPass /cloud http://127.0.0.1:40001/cloud retry=0
ProxyPassReverse /cloud http://127.0.0.1:40001/cloud

And that works, but only in testing mode, since periodically 000-default.conf and default-ssl.conf are overwritten, and manual edits are lost.

So I went to the Univention templates folder, read the Python source, and found that 000-default.conf and default-ssl.conf are written using values from the app cache, as per the following snippet taken from /etc/univention/templates/files/etc/apache2/sites-available/000-default.d/10univention-appcenter:

for app_id, container_port, host_port in app_ports():
        app = Apps().find(app_id)
        if app and app.auto_mod_proxy and app.has_local_web_interface():
                web_interface = app.web_interface
                scheme = app.web_interface_proxy_scheme
                if scheme == 'both':
                        scheme = 'http'
                if app.web_interface_port_http == container_port:
                        print '''
        ProxyPass %(web_interface)s %(scheme)s://127.0.0.1:%(web_port)s%(web_interface)s retry=0
        ProxyPassReverse %(web_interface)s %(scheme)s://127.0.0.1:%(web_port)s%(web_interface)s''' % {'id': app.id, 'web_interface': web_interface, 'web_port': host_port, 'scheme': scheme}
                else:
                        # not relevant for mod_proxy
                        continue

All is clear up to this point, although not immediate for me (has been ages since I used python, and all in all I’m a Linux noob, but making a bif of exercise is always useful :slight_smile: )

Where I got stuck is: how can I change the value of web_interface?

From what I’ve seen the value comes directly from the app cache which mirrors the content of Univention’s repository, and there is no way to customize it.

So, although the appliance allows to customize the Owncloud app in order to change its overwrite.cli.url value, this happens within the Owncloud docker container. But the “glue” with the external world, that is the 000-default.conf and ssl-default.conf files at the host level, are not changed accordingly, and I couldn’t find a way to configure them correctly in an automatic way.

In the LDAP directory there is an object which represents the Owncloud app’s metadata, and it has a Web Interface attribute which I changed from /owncloud to /cloud.

In UCR, there is a variable ucs/web/overview/entries/service/owncloud/link which I changed in the same way.

Maybe I did something wrong, but neither changes triggered any rewriting of 000-default.conf and ssl-default.conf.

At the current time, I’m using a brute-force solution: take 000-default.conf and ssl-default.conf, copy them to 0000-default.conf and 0000-ssl-default.conf, and edit them as needed :frowning:

Since they are processed before the two other files, their <VirtualHosts …> directives (and ProxyPass / ProxyPassReverse within them) win, so my non default URL works correctly, but I would prefer an official solution. Is it possible at the current time?

Thank you for your help and support,
Andrea

Hello Andrea,

how about an overwrite in /etc/univention/templates/files/etc/apache2/sites-available/000-default.d/10univention-appcenter like?

if app and app.auto_mod_proxy and app.has_local_web_interface() and app_id == 'owncloud':
                web_interface = 'cloud'

I’ve used a similar approach here to create a subdomain for nextcloud.
The above suggested code is really a very simple overwrite and of course it is always advised to not change the original template files. More, it only won’t break your apache setting if owncloud is the only app you are going to use.
But you could create your own vhost-template for this and register it. (In the linked thread - I think there is a ucr-command missing. You would have to run ucr update see in the docs )

Edit: the more I look at the code, the uglier it gets… but I still hope it helps to develop something nicer…

Best,
Bernd

Hello Bernd, your proposal is interesting and I would tag it as “cleaner” than mine, except for one thing: an update of the Univention software (either major or minor, at the errata level) could overwrite the Univention templates, and the next time they are applied they would generate “broken” 000-default.conf and default-ssl.conf.

This is the reason I created new .conf files, which I think should survive in case the Univention templates are updated. Of course this would become a problem, if the templates were changed so that they work properly… The goods and cons of workarounds… :slight_smile:

The main reason of this post, however, is this: I wanted to be sure that I’ve not missed some fundamental point. If the templates are based solely on the AppCache, and they don’t take into account owncloud’s metadata (either in LDAP and in app’s config data), I’ve done nothing wrong and the solution is really half baked, for what concerns using a non standard URL.

Hopefully this will be fixed, although it looks like the majority of people sticks to /owncloud, so fixing this problem isn’t urgent from a developer’s perspective.

Thank you for your reply
Andrea

Mastodon