mirror of
https://github.com/freedombox/FreedomBox.git
synced 2026-11-29 08:25:10 +00:00
nextcloud: Drop network namespacing in container, use host network
- This is not ideal and reduces security. However it simplifies quite a bit of setup. - Services on the host network are already exposed to the container (however, they could easily be protected with firewall rules). - Container has full access to external networks already. So this part does not change. - This setup would be at par with how other services run on FreedomBox right now. We can think of generalized solution for all the apps later. - FirewallLocalProtection for the single service the runs in the container works as usual without change. Signed-off-by: Sunil Mohan Adapa <sunil@medhas.org> Reviewed-by: James Valleroy <jvalleroy@mailbox.org>
This commit is contained in:
1 parent
3f8874f461
commit
e7e1a6b41d
2 files changed
+6
-54
No files matched your search
@@ -15,9 +15,6 @@ import augeas
|
||||
from plinth import action_utils
|
||||
from plinth.actions import privileged
|
||||
|
||||
NETWORK_NAME = 'nextcloud-fbx'
|
||||
BRIDGE_IP = '172.16.16.1'
|
||||
CONTAINER_IP = '172.16.16.2'
|
||||
CONTAINER_NAME = 'nextcloud-freedombox'
|
||||
SERVICE_NAME = 'nextcloud-freedombox'
|
||||
VOLUME_NAME = 'nextcloud-volume-freedombox'
|
||||
@@ -58,15 +55,10 @@ def setup():
|
||||
'/run/slapd/ldapi': '/run/slapd/ldapi',
|
||||
VOLUME_NAME: '/var/www/html'
|
||||
}
|
||||
env = {'TRUSTED_PROXIES': BRIDGE_IP, 'OVERWRITEWEBROOT': '/nextcloud'}
|
||||
action_utils.podman_create(network_name=NETWORK_NAME,
|
||||
subnet='172.16.16.0/24', bridge_ip=BRIDGE_IP,
|
||||
host_port='8181', container_port='80',
|
||||
container_ip=CONTAINER_IP,
|
||||
container_name=CONTAINER_NAME,
|
||||
env = {'TRUSTED_PROXIES': '127.0.0.1', 'OVERWRITEWEBROOT': '/nextcloud'}
|
||||
action_utils.podman_create(container_name=CONTAINER_NAME,
|
||||
image_name=IMAGE_NAME, volumes=volumes, env=env)
|
||||
action_utils.service_start(CONTAINER_NAME)
|
||||
_configure_firewall(action='add', interface_name=NETWORK_NAME)
|
||||
|
||||
# OCC isn't immediately available after the container is spun up.
|
||||
# Wait until CAN_INSTALL file is available.
|
||||
@@ -156,14 +148,6 @@ def set_default_phone_region(region: str):
|
||||
_run_occ('config:system:set', 'default_phone_region', '--value', region)
|
||||
|
||||
|
||||
def _configure_firewall(action, interface_name):
|
||||
subprocess.run([
|
||||
'firewall-cmd', '--permanent', '--zone=trusted',
|
||||
f'--{action}-interface={interface_name}'
|
||||
], check=True)
|
||||
action_utils.service_restart('firewalld')
|
||||
|
||||
|
||||
def _database_query(query: str):
|
||||
"""Run a database query."""
|
||||
subprocess.run(['mysql'], input=query.encode(), check=True)
|
||||
@@ -292,9 +276,7 @@ WantedBy=timers.target
|
||||
def uninstall():
|
||||
"""Uninstall Nextcloud"""
|
||||
_drop_database()
|
||||
_configure_firewall(action='remove', interface_name=NETWORK_NAME)
|
||||
action_utils.podman_uninstall(container_name=CONTAINER_NAME,
|
||||
network_name=NETWORK_NAME,
|
||||
volume_name=VOLUME_NAME,
|
||||
image_name=IMAGE_NAME)
|
||||
for path in [_cron_service_file, _cron_timer_file]:
|
||||
|
||||
Reference in new issue
Block a user