After creating application using iectl publisher standalone-app create
To create an app version, you can use the NGINX reverse proxy to redirect traffic to your application. Below yaml is used as an example.
version: "2.4"
services:
nginx:
image: nginx:alpine
restart: always
mem_limit: 200m
To set the application version up, use the following command:
iectl publisher standalone-app version create \
--appname "Example App" \
--yamlpath "/path/to/folder/with/docker-compose.yaml" \
--versionnumber "1.0.0" \
--nginxjson '{"nginx":[{"name":"nginx","protocol":"HTTP","port":"80","headers":"{\"proxy_http_version\":\"1.1\",\"proxy_set_header Upgrade\":\"$http_upgrade\",\"proxy_set_header Connection\":\"\\\"upgrade\\\"\",\"proxy_set_header Host\":\"$host\",\"proxy_set_header X-Real_IP\":\"$remote_addr\",\"proxy_set_header X-Forwarded-For\":\"$proxy_add_x_forwarded_for\",\"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-Uri\": \"$request_uri\"}","rewriteTarget":"","subPath":"","isSecureRedirection":true}]}' \ # nginxjson is json map of docker compose service names and arrays of reverse proxy settings.
--redirectsection "nginx" \ # servicename
--redirecttype "FromBoxReverseProxy" \ # type: redirect via reverse proxy
--redirecturl "ui/" \ # URL path matching pattern: name of location (name + rewriteTarget) with a trailing slash and no leading slash
--restredirecturl "" \ # subpath to be added
When the app is installed on an Edge Device, the NGINX settings would look similar to the following example, assuming the service IP in the proxy-redirect network is 10.10.10.10:
location = /ui {
rewrite /ui/(.*) /$1 break;
rewrite (^/ui)$ $1/ permanent;
}
location ~* ^/ui\/ {
auth_request /auth;
rewrite /ui/(.*) /$1 break;
rewrite /ui/ / break;
rewrite (^/ui)$ $1/ permanent;
proxy_pass http://10.10.10.10:80;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real_IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
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-Uri: $request_uri;
}
NOTICE
This configuration already includes recommended directives to support accessing your application with remote access from IEM. Please carefully consider rewriteTarget and redirecturl as well as restredirecturl like shown in the example.