Skip to content

Commit

Permalink
feat: multi-channel with multi ICM support (#536,#420)
Browse files Browse the repository at this point in the history
Closes #420
  • Loading branch information
dhhyi authored Feb 19, 2021
1 parent 53f602a commit 434ed47
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
6 changes: 6 additions & 0 deletions docs/guides/nginx-startup.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,12 @@ All other properties are optional:
- **lang**: The default language as defined in the Angular CLI environment
- **theme**: The theme used for the channel (format: `<theme-name>(|<icon-color>)?`)

Dynamically directing the PWA to different ICM installations can by done by using:

- **icmHost**: the domain where the ICM instance is running (without protocol and port)
- **icmPort**: (optional) if the port differs from 443
- **icmScheme**: (optional) if the protocol differs from 'https'

Multiple channels can also be configured via context paths, which re-configure the PWA upstream to use a different `baseHref` for each channel.

```yaml
Expand Down
5 changes: 4 additions & 1 deletion nginx/channel.conf.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@
{{- $features := "" }}{{ if (has . "features") }}{{ $features = join ( slice ";features" .features ) "=" }}{{ end }}
{{- $theme := "" }}{{ if (has . "theme") }}{{ $theme = join ( slice ";theme" .theme ) "=" }}{{ end }}
{{- $baseHref := "/" }}{{ if (has . "baseHref") }}{{ $baseHref = .baseHref }}{{ end }}
{{- $icmScheme := "" }}{{ if (has . "icmScheme") }}{{ $icmScheme = join ( slice "icmScheme" .icmScheme ) "=" }}{{ end }}
{{- $icmPort := "" }}{{ if (has . "icmPort") }}{{ $icmPort = join ( slice "icmPort" .icmPort ) "=" }}{{ end }}
{{- $icmHost := "default" }}{{ if (has . "icmHost") }}{{ $icmHost = .icmHost }}{{ end }}
proxy_set_header Host $http_host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
Expand All @@ -28,7 +31,7 @@

rewrite '^(?!.*;lang=.*)(.*)$' '$1;lang={{ $lang }}';

set $default_rewrite_params ';icmHost=default;channel={{ $channel }}{{ $application }}{{ $identityProvider }}{{ $features }}{{ $theme }};baseHref={{ $baseHref | strings.ReplaceAll "/" "%2F" }};device=$ua_device';
set $default_rewrite_params ';icmHost={{ $icmHost }}{{ $icmScheme }}{{ $icmPort }};channel={{ $channel }}{{ $application }}{{ $identityProvider }}{{ $features }}{{ $theme }};baseHref={{ $baseHref | strings.ReplaceAll "/" "%2F" }};device=$ua_device';

rewrite '^(.*)$' '$1$default_rewrite_params' break;

Expand Down
4 changes: 3 additions & 1 deletion src/app/core/configurations/configuration.meta.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,9 @@ function extractConfigurationParameters(state: ConfigurationState, paramMap: Sim
.reduce((acc, val) => ({ ...acc, ...val }), {});

if (paramMap.has('icmHost') && paramMap.get('icmHost') !== 'default') {
properties.baseURL = `${paramMap.get('icmScheme') || 'https'}://${paramMap.get('icmHost')}`;
const scheme = paramMap.get('icmScheme') || 'https';
const port = paramMap.get('icmPort') || '443';
properties.baseURL = `${scheme}://${paramMap.get('icmHost')}:${port}`;
}

if (paramMap.has('features') && paramMap.get('features') !== 'default') {
Expand Down

0 comments on commit 434ed47

Please sign in to comment.