| title | geometry | header-includes |
|---|---|---|
dox |
a4paper |
\usepackage{fourier}
|
Docker API proxy : allow filtered (regexp) access to Docker API thru docker.sock
- GUI with HTML directly embedded GO templates
DRAFT - incomplete doc
- a linux server
- an apache server with php enabled
- gcc
- bash
- golang
- root access
- should I mention a running dockerd
-
git cloneto/opt/dox -
compile demux.c :
gcc -odemux demux.c -
compile gotemp.go :
go build golang.go -
apache : alias
/dox/(URL) to/opt/dox/publish/dox/(FS) -
create proxying user :
sudo adduser dockerlogs -
add user to
dockergroup \ -
sudo visudo -f /etc/sudoers.d/dockerlogsCmnd_Alias DCOM = /opt/dox/bin/dox * User_Alias DUSERS = www-data, %dockerlogs DUSERS ALL = (dockerlogs) NOPASSWD: DCOM -
change
BDIRvalue in/opt/dox/bin/doxto match installation directory -
add/remove regexps in
dox-regexp.txtto allow/disallow docker WS accesses
Supposing the request is to be sent at https://docker-host.bzh/dox, like in https://docker-host.bzh/dox/version
- the apache
.htaccessrewrite the request todox.php - the actual Docket WS path is extracted
- and passed to
doxbash script. The-xparameter tellsdoxbash script to output the correct content-type - dox check if the WS is allowed
- if yes call the actual Docker WS
- if the WS is tagged as "stream" it uses the demux tool to output a plain text file (for logs for example)
There are a few differences between the genuine API and the proxied ones.
- there's no multiplexed stream output, everything is returned flat
- lightweight PHP app structure with a DoxApp application singleton
- inline GO template for JSON to HTML conversion
doxplus.phpreceives a WS request and a GO Template. It runs thedoxbash script and uses the result to rungotempagainst the template, returning plain HTML to be dealt by jQuery- same requisites as previous + golang