2021-04-27 15:27:46 +02:00
2021-04-27 15:23:41 +02:00
2021-04-27 15:23:41 +02:00
2021-04-27 15:23:41 +02:00
2021-04-27 15:23:41 +02:00
2021-04-27 15:23:41 +02:00
2021-04-27 15:23:44 +02:00
2021-04-27 15:27:44 +02:00
2021-04-27 15:23:41 +02:00
2021-04-27 15:23:44 +02:00
2021-04-27 15:23:44 +02:00
2021-04-27 15:23:41 +02:00
2021-04-27 15:23:41 +02:00

proxy

This proxy is based on NGINX. The NGINX configuration is generated by a simple Node.js script which parses the docker socket. NGINX acts as a reverse proxy server. The Node.js script reads the docker socket file to generate a configuration for each running docker container. The base template for configuration is nginx.conf.template All *.template files are written with mustache-js syntax. The templates are assembled by the Node.js program.

Docker Mapping

The Node.js script reads out the /var/run/docker.sock to get the containers of the host system via dockerode.

Important: The proxy expects your backend containers to provide following structure:

  • stapps.version-label of docker container to be set to a valid active version. See configuration....
  • Service name for the backend container should be backend in docker-compose.yml. If you don't use docker-compose set com.docker.compose.service-label to backend.
  • The proxy container to run with --net="host"
  • A port exposed to the host machine. If you want to expose it only to the host machines internal loopback use following

syntax: 127.0.0.1:3000-3500:3000 in docker-compose or docker ports configuration. This will attach the internal 3000 port to the host's loopback on any port between 3000-3500. The proxy will see in the docker.sock which port and ip was chosen. Internal loopback should be 127.0.0.1 tho.

Configuration (Status Codes)

Config files can be added by multiple universities (adding files like config/default-b-tu) and selected via the NODE_APP_INSTANCE environment variable.

  • OutdatedVersions return a HTTP 404
  • ActiveVersions return a HTTP 503 if currently unavailable or the given code by running backend-node
  • Unsupported versions (not configured as outdated or active) return a HTTP 404
  • No version header given returns a HTTP 300

NOTE: The default configuration expects the client to set a version header: X-StApps-Version=<version of app>

Logger

The proxy uses @stapps/logger. You can provide NODE_ENV=production and SMTP-Configuration via environment-variables for monitoring in production use.

Usage

Without ssl:

docker run --rm -v /var/run/docker.sock:/var/run/docker.sock --net="host" gitlab-registry.tubit.tu-berlin.de/stapps/proxy/master

With ssl:

docker run --rm --net="host" \
    -v /var/run/docker.sock:/var/run/docker.sock \
    -v <path to *.crt-file>:/etc/nginx/certs/ssl.crt \
    -v <path to *.key-file>:/etc/nginx/certs/ssl.key \
    -v <path to certificate chain (*.crt) file>:/etc/nginx/certs/chain.crt \
    -v <path to dhparam.pem file>:/etc/nginx/certs/dhparam.pem \
    gitlab-registry.tubit.tu-berlin.de/stapps/proxy/master

Static Folder (docker run option: -v <path to static folder>:/static)

Der Zugriff erfolgt über: http(s)://<url>/_static/<path-to-file>

Beispiel Proxy auf Localhost für die Datei static/test.json: http://localhost/_static/test.json

Bilder im Static Folder

Bilder sollten folgendermaßen abgelegt und benannt werden:

<pfad analog zur imageURL aus der App>/<type>/<uid>-<size>.[jpg|png|gif]

Beispiel: _static/images/Place/hautpmensa-thumbnail.jpg

Aufgerufen wird das mit: 'https://server.deiner.uni.de/_static/images/Place/hauptmensa-thumbnail'

Bildgrößen sind: thumbnail, small, medium, large

Description
Monorepo that contains all projects for the Open StApps project.
Readme 56 MiB
Languages
TypeScript 85.8%
HTML 7.5%
SCSS 4%
JavaScript 1.6%
Dockerfile 0.4%
Other 0.5%