Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

app_api tries to connect ExApps via localhost #231

Closed
scpcom opened this issue Feb 14, 2024 · 6 comments
Closed

app_api tries to connect ExApps via localhost #231

scpcom opened this issue Feb 14, 2024 · 6 comments

Comments

@scpcom
Copy link

scpcom commented Feb 14, 2024

Describe the bug

While the communication between Deploy Daemon and app_api works fine, the communication between app_api and ExApps is broken on my setup.

Steps/Code to Reproduce

  1. Install app_api app in Nextcloud
    sudo -u www-data php occ app:install app_api

  2. Install docker and nextcloud-appapi-dsp on another machine

docker run -e NC_HAPROXY_PASSWORD="$uper$ecret" \
  -e BIND_ADDRESS="10.1.2.5" \
  -v /var/run/docker.sock:/var/run/docker.sock \
  --name nextcloud-appapi-dsp -h nextcloud-appapi-dsp --net host \
  --restart unless-stopped --privileged -d ghcr.io/cloud-py-api/nextcloud-appapi-dsp:release
  1. Goto /settings/admin/app_api and add the Deploy Daemon via docker-socket-proxy template

  2. Try to install context_chat_backend or any other ExApp via the web interface or:

sudo -u www-data php occ app_api:app:deploy context_chat_backend
# Container gets deployed and running but fails to verify that the init is done.
# WA: Manually register the app:
sudo -u www-data php occ app_api:app:register context_chat_backend docker_socket_proxy --force-scopes
# ..and enable it:
sudo -u www-data php occ app_api:app:enable context_chat_backend
# Error happening, see below
  1. Dumb workaround:
    Forward the ports with ssh and install the app again:
root@nextcloud:~# ssh -L 23000:127.0.0.1:23000 -L 23001:127.0.0.1:23001 -L 23002:127.0.0.1:23002 -L 23003:127.0.0.1:23003 portfwd@10.1.2.5

Expected Results

ExApp gets listed as installed and enabled.

Actual Results

[app_api] Fehler: Failed to enable ExApp context_chat_backend. Error: cURL error 7: Failed to connect to localhost port 23000 after 0 ms: Couldn't connect to server (see https://curl.haxx.se/libcurl/c/libcurl-errors.html) for http://localhost:23000/enabled?enabled=1

Setup configuration

app_api = 2.0.4
nextcloud = 28.0.2

@bigcat88
Copy link
Member

Can you describe your setup config a little bit more? Cause it should connect to localhost by design in some situations

Are you using VPN?

@scpcom
Copy link
Author

scpcom commented Feb 14, 2024

Nextcloud is running inside a LXC container with with Apache on Debian 12.
Docker is running on the LXD host on Debian 12 (amd64).

@bigcat88
Copy link
Member

Unfortunately this type of installation is supported either with the workaround that you described, or you will have to use HTTPS and in that case HaProxy(nextcloud-appapi-dsp) will forward requests to LXD localhost and ExApp will listen to that interface(LXD localhost)

Another solution will be to create docker bridge network and make containers in it visible by DNS names from LXC container

@scpcom
Copy link
Author

scpcom commented Feb 14, 2024

OK, thanks. Sounds both like a useful solution, I will try this on a second system that is setup the same way.
On my current setup I will keep the WA until the other one is working.

@Hyp3rSoniX
Copy link

Oh... well in the meantime I managed to create a huge mess on my system...

I ran:

occ app_api:app:register context_chat_backend manual_install --json-info \
"{\"appid\":\"context_chat_backend\",\"name\":\"Context Chat Backend\",\"daemon_config_name\":\"docker_install\",\"version\":\"2.0.1\",\"secret\":\"12345\",\"port\":10034,\"scopes\":[],\"system_app\":0}" \
--force-scopes --wait-finish

In my wisdom... I though it would help to rename manual_install to docker_install.

And now I can't unregister it anymore... Even deleting App Api and reinstalling it doesn't help.

I'm currently at work, so I can't access the system to show the stacktrace, but on the top of your head... is there anything I can do to at least fix the registered value docker_install so I can unregister it again?

@bigcat88
Copy link
Member

bigcat88 commented Apr 3, 2024

no, worry.
you can always just manually remove containers and clean oc_ex_apps/oc_ex_apps_daemons table(after cleaning tables reset Redis cache if you have one)

or you can use occ app_api:app:unregister "appid" --force

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants