Skip to content

Create App Version with Reverse Proxy

After creating application using iectl publisher standalone-app create

You can create an app version by using the nginx reverse proxy with the following command:

# examples are based on given yaml
version: "2.4" 
services: 
  nginx: #serviceName to be used in --redirectsection, to tell device to use this service for app redirection.
    image: nginx:alpine 
    restart: always 
    mem_limit: 200m
$ iectl publisher standalone-app version create \
        --appname "my cool app" \
        --yamlpath "/path/to/folder/with/docker-compose.yaml" \ 
        --versionnumber "1.0.0" \
        --nginxjson '{"nginx":[{"name":"ui","protocol":"HTTPS","port":"80","headers":"","rewriteTarget":"/"}]}' \ # nginxjson is json map of docker compose service name and array of reverse proxy.
        --redirectsection "nginx" \         # redirectsection requires the service name within docker-compose which contains the container that shall be exposed
        --redirecttype "FromBoxReverseProxy" \  # redirecttype is either FromBoxSpecificPort for direct port exposure or FromBoxReverseProxy for reverse proxy exposure
        --redirecturl "ui/" \                   # redirecturl is the port which shall be exposed from your container
        --restredirecturl "" \                  # restredirecturl path will be used upon redirect to your application

The nginx settings will look as follows for example when the app is installed on an Edge Device:

location ~* ^/ui\/?(?<baseuri>.*) {
 auth_request /auth;
  rewrite /ui/(.*) /&1 break;
  rewrite /ui / break;
  proxy_pass https://<ip>:80;
  proxy_http_version 1.1;
  proxy_set_header Upgrade $http_upgrade;
  proxy_set_header Connection "upgrade";
  proxy_set_header X-Forwarded-Protocol $scheme;
  proxy_set_header X-Forwarded-Host $host;
  proxy_set_header X-Forwarded-Port $server_port;
  proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
  proxy_set_header X-Real-IP $remote_addr;
  proxy_set_header Host $host;
  proxy_set_header X-Forwarded-Uri $request_uri;