diff --git a/plinth/modules/ejabberd/__init__.py b/plinth/modules/ejabberd/__init__.py
index 22276b5de..b4ebd11b1 100644
--- a/plinth/modules/ejabberd/__init__.py
+++ b/plinth/modules/ejabberd/__init__.py
@@ -50,7 +50,7 @@ class EjabberdApp(app_module.App):
app_id = 'ejabberd'
- _version = 4
+ _version = 5
def __init__(self):
"""Create components for the app."""
diff --git a/plinth/modules/ejabberd/data/etc/apache2/conf-available/jwchat-plinth.conf b/plinth/modules/ejabberd/data/etc/apache2/conf-available/jwchat-plinth.conf
index e76c32809..847228f8e 100644
--- a/plinth/modules/ejabberd/data/etc/apache2/conf-available/jwchat-plinth.conf
+++ b/plinth/modules/ejabberd/data/etc/apache2/conf-available/jwchat-plinth.conf
@@ -4,3 +4,11 @@ ProxyPassReverse /bosh/ http://localhost:5443/bosh/
Require all granted
+
+##
+## Proxy for XEP-0363 HTTP File Upload
+##
+
+ ProxyPreserveHost On
+ ProxyPass http://localhost:5443/upload/
+
diff --git a/plinth/modules/ejabberd/privileged.py b/plinth/modules/ejabberd/privileged.py
index 4e6037d1f..d0e9c3bd4 100644
--- a/plinth/modules/ejabberd/privileged.py
+++ b/plinth/modules/ejabberd/privileged.py
@@ -55,6 +55,28 @@ def setup(domainname: str):
listen_port['tls'] = False
if 'use_turn' in listen_port:
conf['listen'].remove(listen_port) # Use coturn instead
+ if listen_port['port'] == 5443:
+ # Enable XEP-0363 HTTP File Upload
+ listen_port['request_handlers']['/upload'] = 'mod_http_upload'
+
+ origin_key = scalarstring.DoubleQuotedScalarString(
+ 'Access-Control-Allow-Origin')
+ origin_value = scalarstring.DoubleQuotedScalarString('https://@HOST@')
+ methods_key = scalarstring.DoubleQuotedScalarString(
+ 'Access-Control-Allow-Methods')
+ methods_value = scalarstring.DoubleQuotedScalarString(
+ 'GET,HEAD,PUT,OPTIONS')
+ headers_key = scalarstring.DoubleQuotedScalarString(
+ 'Access-Control-Allow-Headers')
+ headers_value = scalarstring.DoubleQuotedScalarString('Content-Type')
+ conf['modules']['mod_http_upload'] = {
+ 'put_url': 'https://@HOST@/upload',
+ 'custom_headers': {
+ origin_key: origin_value,
+ methods_key: methods_value,
+ headers_key: headers_value,
+ },
+ }
conf['auth_method'] = 'ldap'
conf['ldap_servers'] = [scalarstring.DoubleQuotedScalarString('localhost')]