-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathDeployConfigurations.html
498 lines (456 loc) · 31 KB
/
DeployConfigurations.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
<!DOCTYPE html>
<html class="writer-html5" lang="en" data-content_root="./">
<head>
<meta charset="utf-8" /><meta name="viewport" content="width=device-width, initial-scale=1" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Deployment configurations — AppAPI latest documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=80d5e7a1" />
<link rel="stylesheet" type="text/css" href="_static/css/theme.css?v=19f00094" />
<link rel="stylesheet" type="text/css" href="_static/copybutton.css?v=76b2166b" />
<link rel="stylesheet" type="text/css" href="_static/tabs.css?v=4c969af8" />
<link rel="stylesheet" type="text/css" href="_static/css/styles.css?v=92f2225a" />
<link rel="stylesheet" type="text/css" href="_static/css/dark.css?v=41caee7b" />
<link rel="stylesheet" type="text/css" href="_static/css/light.css?v=c3d70dd7" />
<!--[if lt IE 9]>
<script src="_static/js/html5shiv.min.js"></script>
<![endif]-->
<script src="_static/jquery.js?v=5d32c60e"></script>
<script src="_static/_sphinx_javascript_frameworks_compat.js?v=2cd50e6c"></script>
<script src="_static/documentation_options.js?v=c6e86fd7"></script>
<script src="_static/doctools.js?v=9a2dae69"></script>
<script src="_static/sphinx_highlight.js?v=dc90522c"></script>
<script src="_static/clipboard.min.js?v=a7894cd8"></script>
<script src="_static/copybutton.js?v=f281be69"></script>
<script src="_static/tabs.js?v=3ee01567"></script>
<script src="_static/js/script.js?v=783f4f19"></script>
<script src="https://unpkg.com/mermaid@10.2.0/dist/mermaid.min.js"></script>
<script>mermaid.initialize({startOnLoad:true});</script>
<script src="_static/js/theme.js"></script>
<link rel="index" title="Index" href="genindex.html" />
<link rel="search" title="Search" href="search.html" />
<link rel="next" title="Creation of Deploy Daemon" href="CreationOfDeployDaemon.html" />
<link rel="prev" title="Installation" href="Installation.html" />
</head>
<body class="wy-body-for-nav">
<div class="wy-grid-for-nav">
<nav data-toggle="wy-nav-shift" class="wy-nav-side">
<div class="wy-side-scroll">
<div class="wy-side-nav-search" >
<a href="index.html" class="icon icon-home">
AppAPI
<img src="_static/logo.svg" class="logo" alt="Logo"/>
</a>
<div role="search">
<form id="rtd-search-form" class="wy-form" action="search.html" method="get">
<input type="text" name="q" placeholder="Search docs" aria-label="Search docs" />
<input type="hidden" name="check_keywords" value="yes" />
<input type="hidden" name="area" value="default" />
</form>
</div>
</div><div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="Navigation menu">
<ul class="current">
<li class="toctree-l1"><a class="reference internal" href="Installation.html">Installation</a></li>
<li class="toctree-l1 current"><a class="current reference internal" href="#">Deployment configurations</a><ul>
<li class="toctree-l2"><a class="reference internal" href="#docker-deploy-daemon">Docker Deploy Daemon</a><ul>
<li class="toctree-l3"><a class="reference internal" href="#nc-docker-on-the-same-host">NC & Docker on the Same-Host</a></li>
<li class="toctree-l3"><a class="reference internal" href="#docker-on-a-remote-host">Docker on a remote host</a></li>
<li class="toctree-l3"><a class="reference internal" href="#nc-exapps-in-the-same-docker">NC & ExApps in the same Docker</a></li>
<li class="toctree-l3"><a class="reference internal" href="#nextcloud-in-docker-aio-all-in-one">Nextcloud in Docker AIO (all-in-one)</a><ul>
<li class="toctree-l4"><a class="reference internal" href="#default-aio-deploy-daemon">Default AIO Deploy Daemon</a></li>
<li class="toctree-l4"><a class="reference internal" href="#docker-socket-proxy-security">Docker Socket Proxy security</a></li>
</ul>
</li>
</ul>
</li>
<li class="toctree-l2"><a class="reference internal" href="#nc-to-exapp-communication">NC to ExApp Communication</a></li>
</ul>
</li>
<li class="toctree-l1"><a class="reference internal" href="CreationOfDeployDaemon.html">Creation of Deploy Daemon</a></li>
<li class="toctree-l1"><a class="reference internal" href="TestDeploy.html">Test Deploy Daemon</a></li>
<li class="toctree-l1"><a class="reference internal" href="ManagingExternalApplications.html">Managing External Applications</a></li>
<li class="toctree-l1"><a class="reference internal" href="Concepts.html">Concepts</a></li>
<li class="toctree-l1"><a class="reference internal" href="tech_details/index.html">Technical details</a></li>
<li class="toctree-l1"><a class="reference internal" href="DevSetup.html">Setting up dev environment</a></li>
<li class="toctree-l1"><a class="reference internal" href="notes_for_developers/index.html">Notes for Developers</a></li>
<li class="toctree-l1"><a class="reference internal" href="faq/index.html">Frequently Asked Questions</a></li>
</ul>
</div>
</div>
</nav>
<section data-toggle="wy-nav-shift" class="wy-nav-content-wrap"><nav class="wy-nav-top" aria-label="Mobile navigation menu" >
<i data-toggle="wy-nav-top" class="fa fa-bars"></i>
<a href="index.html">AppAPI</a>
</nav>
<div class="wy-nav-content">
<div class="rst-content">
<div role="navigation" aria-label="Page navigation">
<ul class="wy-breadcrumbs">
<li><a href="index.html" class="icon icon-home" aria-label="Home"></a></li>
<li class="breadcrumb-item active">Deployment configurations</li>
<li class="wy-breadcrumbs-aside">
<a href="_sources/DeployConfigurations.rst.txt" rel="nofollow"> View page source</a>
</li>
</ul>
<hr/>
</div>
<div role="main" class="document" itemscope="itemscope" itemtype="http://schema.org/Article">
<div itemprop="articleBody">
<section id="deployment-configurations">
<span id="deploy-configs"></span><h1>Deployment configurations<a class="headerlink" href="#deployment-configurations" title="Link to this heading"></a></h1>
<dl class="simple">
<dt>Currently, only one kind of application deployment is supported:</dt><dd><ul class="simple">
<li><p><strong>Docker Deploy Daemon</strong></p></li>
</ul>
</dd>
</dl>
<section id="docker-deploy-daemon">
<h2>Docker Deploy Daemon<a class="headerlink" href="#docker-deploy-daemon" title="Link to this heading"></a></h2>
<p>Orchestrates the deployment of applications as Docker containers.</p>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>The administrator is responsible for the security actions taken to configure the Docker daemon connected to the Nextcloud instance.</p>
<p>These schemes are only examples of possible configurations.</p>
<p>We recommend that you use the <a class="reference external" href="https://github.com/cloud-py-api/docker-socket-proxy">AppAPI Docker Socket Proxy</a> or <a class="reference external" href="#nextcloud-in-docker-aio-all-in-one">AIO Docker Socket Proxy</a> container.</p>
</div>
<p>There are several Docker Daemon Deploy configurations (example schemes):</p>
<blockquote>
<div><ul class="simple">
<li><p>Nextcloud and Docker on the <strong>same host</strong> (via socket or DockerSocketProxy)</p></li>
<li><p>Nextcloud on the host and Docker on a <strong>remote</strong> host (via DockerSocketProxy with HTTPS)</p></li>
<li><p>Nextcloud and <strong>ExApps</strong> in the <strong>same Docker</strong> (via DockerSocketProxy)</p></li>
<li><p>Nextcloud in AIO Docker and <strong>ExApps</strong> in the <strong>same Docker</strong> (via AIO DockerSocketProxy)</p></li>
</ul>
</div></blockquote>
<section id="nc-docker-on-the-same-host">
<h3>NC & Docker on the Same-Host<a class="headerlink" href="#nc-docker-on-the-same-host" title="Link to this heading"></a></h3>
<p>The simplest configuration is when Nextcloud is installed on the host and Docker is on the same host and applications are deployed to it.</p>
<div class="mermaid">
stateDiagram-v2
classDef docker fill: #1f97ee, color: transparent, font-size: 34px, stroke: #364c53, stroke-width: 1px, background: url(https://raw.githubusercontent.com/cloud-py-api/app_api/main/docs/img/docker.png) no-repeat center center / contain
classDef nextcloud fill: #006aa3, color: transparent, font-size: 34px, stroke: #045987, stroke-width: 1px, background: url(https://raw.githubusercontent.com/cloud-py-api/app_api/main/docs/img/nextcloud.svg) no-repeat center center / contain
classDef python fill: #1e415f, color: white, stroke: #364c53, stroke-width: 1px
Host
state Host {
Nextcloud --> Daemon : /var/run/docker.sock
Daemon --> Containers
state Containers {
ExApp1
--
ExApp2
--
ExApp3
}
}
class Nextcloud nextcloud
class Daemon docker
class ExApp1 python
class ExApp2 python
class ExApp3 python
</div><dl class="simple">
<dt>Suggested config values(template <em>Custom default</em>):</dt><dd><ol class="arabic simple">
<li><p>Daemon host: <code class="docutils literal notranslate"><span class="pre">/var/run/docker.sock</span></code></p></li>
<li><p>HTTPS checkbox: <em>not supported using docker socket</em></p></li>
<li><p>Network: <code class="docutils literal notranslate"><span class="pre">host</span></code></p></li>
<li><p>HaProxy password: <strong>not supported using raw docker socket, should be empty</strong></p></li>
</ol>
</dd>
</dl>
<p>—</p>
<p>Suggested way to communicate with Docker via <a class="reference external" href="https://github.com/cloud-py-api/docker-socket-proxy">Docker Socket Proxy container</a>.</p>
<div class="mermaid">
stateDiagram-v2
classDef docker fill: #1f97ee, color: transparent, font-size: 34px, stroke: #364c53, stroke-width: 1px, background: url(https://raw.githubusercontent.com/cloud-py-api/app_api/main/docs/img/docker.png) no-repeat center center / contain
classDef nextcloud fill: #006aa3, color: transparent, font-size: 34px, stroke: #045987, stroke-width: 1px, background: url(https://raw.githubusercontent.com/cloud-py-api/app_api/main/docs/img/nextcloud.svg) no-repeat center center / contain
classDef python fill: #1e415f, color: white, stroke: #364c53, stroke-width: 1px
Host
state Host {
Nextcloud --> DockerSocketProxy: by port
Docker --> Containers
Docker --> DockerSocketProxy : /var/run/docker.sock
state Containers {
DockerSocketProxy --> ExApp1
DockerSocketProxy --> ExApp2
DockerSocketProxy --> ExApp3
}
}
class Nextcloud nextcloud
class Docker docker
class ExApp1 python
class ExApp2 python
class ExApp3 python
</div><dl class="simple">
<dt>Suggested config values(template <em>Docker Socket Proxy</em>):</dt><dd><ol class="arabic simple">
<li><dl class="simple">
<dt>Daemon host: <code class="docutils literal notranslate"><span class="pre">localhost:2375</span></code></dt><dd><dl class="simple">
<dt>Choose <strong>A</strong> or <strong>B</strong> option:</dt><dd><ol class="upperalpha simple">
<li><p>Docker Socket Proxy should be deployed with <code class="docutils literal notranslate"><span class="pre">network=host</span></code> and <code class="docutils literal notranslate"><span class="pre">BIND_ADDRESS=127.0.0.1</span></code></p></li>
<li><p>Docker Socket Proxy should be deployed with <code class="docutils literal notranslate"><span class="pre">network=bridge</span></code> and it’s port should be published to host’s 127.0.0.1(e.g. <strong>-p 127.0.0.1:2375:2375</strong>)</p></li>
</ol>
</dd>
</dl>
</dd>
</dl>
</li>
<li><p>HTTPS checkbox: <strong>disabled</strong></p></li>
<li><p>Network: <code class="docutils literal notranslate"><span class="pre">host</span></code></p></li>
<li><p>HaProxy password: <strong>should not be empty</strong></p></li>
</ol>
</dd>
</dl>
<div class="admonition warning">
<p class="admonition-title">Warning</p>
<p>Be careful with option <code class="docutils literal notranslate"><span class="pre">A</span></code>, by default <strong>Docker Socket Proxy</strong> binds to <code class="docutils literal notranslate"><span class="pre">*</span></code> if <code class="docutils literal notranslate"><span class="pre">BIND_ADDRESS</span></code> is not specified during container creation.
Check opened ports after finishing configuration.</p>
</div>
</section>
<section id="docker-on-a-remote-host">
<h3>Docker on a remote host<a class="headerlink" href="#docker-on-a-remote-host" title="Link to this heading"></a></h3>
<p>Distributed configuration occurs when Nextcloud is installed on one host and Docker is located on a remote host, resulting in the deployment of applications on the remote host.</p>
<p>Benefit: no performance impact on Nextcloud host.</p>
<p>In this case, the AppAPI uses a Docker Socket Proxy deployed on remote host to access docker socket and ExApps.</p>
<div class="mermaid">
stateDiagram-v2
classDef docker fill: #1f97ee, color: transparent, font-size: 34px, stroke: #364c53, stroke-width: 1px, background: url(https://raw.githubusercontent.com/cloud-py-api/app_api/main/docs/img/docker.png) no-repeat center center / contain
classDef nextcloud fill: #006aa3, color: transparent, font-size: 34px, stroke: #045987, stroke-width: 1px, background: url(https://raw.githubusercontent.com/cloud-py-api/app_api/main/docs/img/nextcloud.svg) no-repeat center center / contain
classDef python fill: #1e415f, color: white, stroke: #364c53, stroke-width: 1px
Direction LR
Host1 --> Host2 : by port
state Host1 {
Nextcloud
}
state Host2 {
[*] --> DockerSocketProxy : by port
Daemon --> Containers
state Containers {
[*] --> DockerSocketProxy : /var/run/docker.sock
DockerSocketProxy --> ExApp1
DockerSocketProxy --> ExApp2
DockerSocketProxy --> ExApp3
}
}
class Nextcloud nextcloud
class Daemon docker
class ExApp1 python
class ExApp2 python
class ExApp3 python
</div><dl class="simple">
<dt>Suggested config values(template <em>Docker Socket Proxy</em>):</dt><dd><ol class="arabic simple">
<li><p>Daemon host: ADDRESS_OF_REMOTE_MACHINE (e.g. <strong>server_name.com:2375</strong>)</p></li>
<li><p>HTTPS checkbox: <code class="docutils literal notranslate"><span class="pre">enabled</span></code></p></li>
<li><p>Network: <code class="docutils literal notranslate"><span class="pre">host</span></code></p></li>
<li><p>HaProxy password: <strong>should not be empty</strong></p></li>
</ol>
</dd>
</dl>
</section>
<section id="nc-exapps-in-the-same-docker">
<h3>NC & ExApps in the same Docker<a class="headerlink" href="#nc-exapps-in-the-same-docker" title="Link to this heading"></a></h3>
<p>Applications are deployed in the same docker where Nextcloud resides.</p>
<p>Suggested way to communicate with Docker: via <code class="docutils literal notranslate"><span class="pre">docker-socket-proxy</span></code>.</p>
<div class="mermaid">
stateDiagram-v2
classDef docker fill: #1f97ee, color: transparent, font-size: 34px, stroke: #364c53, stroke-width: 1px, background: url(https://raw.githubusercontent.com/cloud-py-api/app_api/main/docs/img/docker.png) no-repeat center center / contain
classDef nextcloud fill: #006aa3, color: transparent, font-size: 34px, stroke: #045987, stroke-width: 1px, background: url(https://raw.githubusercontent.com/cloud-py-api/app_api/main/docs/img/nextcloud.svg) no-repeat center center / contain
classDef python fill: #1e415f, color: white, stroke: #364c53, stroke-width: 1px
Host
state Host {
Daemon --> Containers
state Containers {
[*] --> DockerSocketProxy : /var/run/docker.sock
Nextcloud --> DockerSocketProxy: by port
--
DockerSocketProxy --> ExApp1
DockerSocketProxy --> ExApp2
}
}
class Nextcloud nextcloud
class Daemon docker
class ExApp1 python
class ExApp2 python
class ExApp3 python
</div><dl class="simple">
<dt>Suggested config values(template <em>Docker Socket Proxy</em>):</dt><dd><ol class="arabic simple">
<li><p>Daemon host: nextcloud-appapi-dsp:2375</p></li>
<li><p>HTTPS checkbox: <code class="docutils literal notranslate"><span class="pre">disabled</span></code></p></li>
<li><p>Network: <a class="reference external" href="https://docs.docker.com/network/#user-defined-networks">user defined network</a></p></li>
<li><p>HaProxy password: <strong>should not be empty</strong></p></li>
</ol>
</dd>
</dl>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Network <strong>should not be the default docker’s bridge</strong> as it does not support DNS resolving by container names.</p>
<p>This means that <strong>Docker Socket Proxy</strong>, <strong>Nextcloud</strong> and <strong>ExApps</strong> containers should all be in the same docker network, different from the default <strong>bridge</strong>.</p>
</div>
</section>
<section id="nextcloud-in-docker-aio-all-in-one">
<span id="id1"></span><h3>Nextcloud in Docker AIO (all-in-one)<a class="headerlink" href="#nextcloud-in-docker-aio-all-in-one" title="Link to this heading"></a></h3>
<p>In case of AppAPI is in Docker AIO setup (installed in Nextcloud container).</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>AIO Docker Socket Proxy container must be enabled.</p>
</div>
<div class="mermaid">
stateDiagram-v2
classDef docker fill: #1f97ee, color: transparent, font-size: 34px, stroke: #364c53, stroke-width: 1px, background: url(https://raw.githubusercontent.com/cloud-py-api/app_api/main/docs/img/docker.png) no-repeat center center / contain
classDef docker2 fill: #1f97ee, color: transparent, font-size: 20px, stroke: #364c53, stroke-width: 1px, background: url(https://raw.githubusercontent.com/cloud-py-api/app_api/main/docs/img/docker.png) no-repeat center center / contain
classDef nextcloud fill: #006aa3, color: transparent, font-size: 34px, stroke: #045987, stroke-width: 1px, background: url(https://raw.githubusercontent.com/cloud-py-api/app_api/main/docs/img/nextcloud.svg) no-repeat center center / contain
classDef python fill: #1e415f, color: white, stroke: #364c53, stroke-width: 1px
Host
state Host {
Daemon --> Containers
state Containers {
[*] --> NextcloudAIOMasterContainer : /var/run/docker.sock
[*] --> DockerSocketProxy : /var/run/docker.sock
NextcloudAIOMasterContainer --> Nextcloud
AppAPI --> Nextcloud : installed in
Nextcloud --> DockerSocketProxy
DockerSocketProxy --> ExApp1
DockerSocketProxy --> ExApp2
DockerSocketProxy --> ExApp3
}
}
class Nextcloud nextcloud
class Daemon docker
class Daemon2 docker2
class ExApp1 python
class ExApp2 python
class ExApp3 python
</div><p>AppAPI will automatically create default default DaemonConfig to use AIO Docker Socket Proxy as orchestrator to create ExApp containers.</p>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Default DaemonConfig will be created only if the default DaemonConfig is not already registered.</p>
</div>
<section id="default-aio-deploy-daemon">
<h4>Default AIO Deploy Daemon<a class="headerlink" href="#default-aio-deploy-daemon" title="Link to this heading"></a></h4>
<p>Nextcloud AIO has a specifically created Docker Socket Proxy container to be used as the Deploy Daemon in AppAPI.
It has <a class="reference external" href="https://github.com/cloud-py-api/app_api/blob/main/lib/DeployActions/AIODockerActions.php#L52-L74)">fixed parameters</a>:</p>
<ul class="simple">
<li><p>Name: <code class="docutils literal notranslate"><span class="pre">docker_aio</span></code></p></li>
<li><p>Display name: <code class="docutils literal notranslate"><span class="pre">AIO</span> <span class="pre">Docker</span> <span class="pre">Socket</span> <span class="pre">Proxy</span></code></p></li>
<li><p>Accepts Deploy ID: <code class="docutils literal notranslate"><span class="pre">docker-install</span></code></p></li>
<li><p>Protocol: <code class="docutils literal notranslate"><span class="pre">http</span></code></p></li>
<li><p>Host: <code class="docutils literal notranslate"><span class="pre">nextcloud-aio-docker-socket-proxy:2375</span></code></p></li>
<li><p>Compute device: <code class="docutils literal notranslate"><span class="pre">CPU</span></code></p></li>
<li><p>Network: <code class="docutils literal notranslate"><span class="pre">nextcloud-aio</span></code></p></li>
<li><p>Nextcloud URL (passed to ExApps): <code class="docutils literal notranslate"><span class="pre">https://$NC_DOMAIN</span></code></p></li>
</ul>
</section>
<section id="docker-socket-proxy-security">
<h4>Docker Socket Proxy security<a class="headerlink" href="#docker-socket-proxy-security" title="Link to this heading"></a></h4>
<p>AIO Docker Socket Proxy has strictly limited access to the Docker APIs described in <a class="reference external" href="https://github.com/nextcloud/all-in-one/blob/main/Containers/docker-socket-proxy/haproxy.cfg">HAProxy configuration</a>.</p>
</section>
</section>
</section>
<section id="nc-to-exapp-communication">
<h2>NC to ExApp Communication<a class="headerlink" href="#nc-to-exapp-communication" title="Link to this heading"></a></h2>
<p>Each type of DeployDaemon necessarily implements the <code class="docutils literal notranslate"><span class="pre">resolveExAppUrl</span></code> function.</p>
<p>It has such prototype:</p>
<div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">public function resolveExAppUrl(</span>
<span class="x"> string $appId, string $protocol, string $host, array $deployConfig, int $port, array &$auth</span>
<span class="x">) {}</span>
</pre></div>
</div>
<p>where:</p>
<ul class="simple">
<li><p><strong>protocol</strong> is daemon protocol value</p></li>
<li><p><strong>host</strong> is daemon host value, <em>can be DNS:port or IP:PORT or even path to docker socket</em>.</p></li>
<li><p><strong>port</strong> is an integer with ExApp port</p></li>
<li><p><strong>deployConfig</strong> can be custom for each Daemon type</p></li>
<li><p><strong>auth</strong> is an optional array, with <em>Basic Authentication</em> data if needed to access ExApp</p></li>
</ul>
<div class="admonition note">
<p class="admonition-title">Note</p>
<p>Starting with AppAPI version <code class="docutils literal notranslate"><span class="pre">2.5.0</span></code>, the optional additional parameter <em>OVERRIDE_APP_HOST</em> can be used to
override the host that will be used for ExApp binding.</p>
<p>It can be <code class="docutils literal notranslate"><span class="pre">0.0.0.0</span></code> in some specific configurations, when VPN is used
or both Nextcloud instance and ExApps are one the same physical machine but different virtual environments.</p>
<p>Also you can specify something like <code class="docutils literal notranslate"><span class="pre">10.10.2.5</span></code> and in this case <code class="docutils literal notranslate"><span class="pre">ExApp</span></code> wil try to bind to that address and
AppAPI will try to send request s directly to this address assuming that ExApp itself bound on it.</p>
</div>
<p>The simplest implementation is in <strong>Manual-Install</strong> deploy type:</p>
<div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">public function resolveExAppUrl(</span>
<span class="x"> string $appId, string $protocol, string $host, array $deployConfig, int $port, array &$auth</span>
<span class="x">): string {</span>
<span class="x"> $auth = [];</span>
<span class="x"> if (isset($deployConfig['additional_options']['OVERRIDE_APP_HOST']) &&</span>
<span class="x"> $deployConfig['additional_options']['OVERRIDE_APP_HOST'] !== ''</span>
<span class="x"> ) {</span>
<span class="x"> $wideNetworkAddresses = ['0.0.0.0', '127.0.0.1', '::', '::1'];</span>
<span class="x"> if (!in_array($deployConfig['additional_options']['OVERRIDE_APP_HOST'], $wideNetworkAddresses)) {</span>
<span class="x"> $host = $deployConfig['additional_options']['OVERRIDE_APP_HOST'];</span>
<span class="x"> }</span>
<span class="x"> }</span>
<span class="x"> return sprintf('%s://%s:%s', $protocol, $host, $port);</span>
<span class="x">}</span>
</pre></div>
</div>
<p>Here we see that AppAPI send requests to <strong>host</strong>:<strong>port</strong> specified during daemon creation.</p>
<p>Now let’s take a look at the Docker Daemon implementation of <code class="docutils literal notranslate"><span class="pre">resolveExAppUrl</span></code>:</p>
<div class="highlight-php notranslate"><div class="highlight"><pre><span></span><span class="x">public function resolveExAppUrl(</span>
<span class="x"> string $appId, string $protocol, string $host, array $deployConfig, int $port, array &$auth</span>
<span class="x">): string {</span>
<span class="x"> $auth = [];</span>
<span class="x"> if (isset($deployConfig['additional_options']['OVERRIDE_APP_HOST']) &&</span>
<span class="x"> $deployConfig['additional_options']['OVERRIDE_APP_HOST'] !== ''</span>
<span class="x"> ) {</span>
<span class="x"> $wideNetworkAddresses = ['0.0.0.0', '127.0.0.1', '::', '::1'];</span>
<span class="x"> if (!in_array($deployConfig['additional_options']['OVERRIDE_APP_HOST'], $wideNetworkAddresses)) {</span>
<span class="x"> return sprintf(</span>
<span class="x"> '%s://%s:%s', $protocol, $deployConfig['additional_options']['OVERRIDE_APP_HOST'], $port</span>
<span class="x"> );</span>
<span class="x"> }</span>
<span class="x"> }</span>
<span class="x"> $host = explode(':', $host)[0];</span>
<span class="x"> if ($protocol == 'https') {</span>
<span class="x"> $exAppHost = $host;</span>
<span class="x"> } elseif (isset($deployConfig['net']) && $deployConfig['net'] === 'host') {</span>
<span class="x"> $exAppHost = 'localhost';</span>
<span class="x"> } else {</span>
<span class="x"> $exAppHost = $appId;</span>
<span class="x"> }</span>
<span class="x"> if (isset($deployConfig['haproxy_password']) && $deployConfig['haproxy_password'] !== '') {</span>
<span class="x"> $auth = [self::APP_API_HAPROXY_USER, $deployConfig['haproxy_password']];</span>
<span class="x"> }</span>
<span class="x"> return sprintf('%s://%s:%s', $protocol, $exAppHost, $port);</span>
<span class="x">}</span>
</pre></div>
</div>
<p>Here we have much more complex algorithm of detecting to where requests should be send.</p>
<p>First of all if protocol is set to <code class="docutils literal notranslate"><span class="pre">https</span></code> AppAPI always send requests to daemon host,
and this is in case of <code class="docutils literal notranslate"><span class="pre">https</span></code> it is a HaProxy that will forward requests to ExApps that will be listen on <code class="docutils literal notranslate"><span class="pre">localhost</span></code></p>
<p>Briefly it will look like this(<em>haproxy_host==daemon host value</em>):</p>
<p>NC –> <em>https</em> –> <code class="docutils literal notranslate"><span class="pre">haproxy_host:ex_app_port</span></code> –> <em>http</em> –> <code class="docutils literal notranslate"><span class="pre">localhost:ex_app_port</span></code></p>
<p>When protocol is not <code class="docutils literal notranslate"><span class="pre">https</span></code> but <code class="docutils literal notranslate"><span class="pre">http</span></code>, then what will be the endpoint where to send requests is determined by <code class="docutils literal notranslate"><span class="pre">$deployConfig['net']</span></code> value.</p>
<p>If <code class="docutils literal notranslate"><span class="pre">net</span></code> is defined and equal to <code class="docutils literal notranslate"><span class="pre">host</span></code> then AppAPI assumes that ExApp is installed somewhere in the current host network and will be available on <code class="docutils literal notranslate"><span class="pre">localhost</span></code> loop-back adapter.</p>
<p>NC –> <em>http</em> –> <code class="docutils literal notranslate"><span class="pre">localhost:ex_app_port</span></code></p>
<p>In all other cases ExApp should be available by it’s name: e.g. when using docker <strong>custom bridge</strong> network all containers available by DNS.</p>
<p>NC –> <em>http</em> –> <code class="docutils literal notranslate"><span class="pre">app_container_name:ex_app_port</span></code></p>
<p>This three different types of communication covers all most popular configurations.</p>
</section>
</section>
</div>
</div>
<footer><div class="rst-footer-buttons" role="navigation" aria-label="Footer">
<a href="Installation.html" class="btn btn-neutral float-left" title="Installation" accesskey="p" rel="prev"><span class="fa fa-arrow-circle-left" aria-hidden="true"></span> Previous</a>
<a href="CreationOfDeployDaemon.html" class="btn btn-neutral float-right" title="Creation of Deploy Daemon" accesskey="n" rel="next">Next <span class="fa fa-arrow-circle-right" aria-hidden="true"></span></a>
</div>
<hr/>
<div role="contentinfo">
<p>© Copyright 2024 Nextcloud GmbH.</p>
</div>
Built with <a href="https://www.sphinx-doc.org/">Sphinx</a> using a
<a href="https://github.com/readthedocs/sphinx_rtd_theme">theme</a>
provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
</div>
</div>
</section>
</div>
<script>
jQuery(function () {
SphinxRtdTheme.Navigation.enable(true);
});
</script>
</body>
</html>