Skip to content

Commit

Permalink
✨ Provide nginx proxy for mitre endpoints
Browse files Browse the repository at this point in the history
  • Loading branch information
C-Valen committed Jan 9, 2025
1 parent 4db30a1 commit 20eb135
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 1 deletion.
4 changes: 3 additions & 1 deletion build/entrypoint.d/20-osim-runtime-json.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ OSIM_BACKENDS_OSIDB_AUTH="${OSIM_BACKENDS_OSIDB_AUTH:-kerberos}"
OSIM_BACKENDS_BUGZILLA="${OSIM_BACKENDS_BUGZILLA:-http://bugzilla-service:8001}"
OSIM_BACKENDS_JIRA="${OSIM_BACKENDS_JIRA:-http://jira-service:8002}"
OSIM_BACKENDS_ERRATA="${OSIM_BACKENDS_ERRATA:-http://errata-service:8003}"
OSIM_BACKENDS_MITRE="${OSIM_BACKENDS_MITRE:-http://mitre-service:8003}"
OSIM_BACKENDS_JIRA_DISPLAY="${OSIM_BACKENDS_JIRA_DISPLAY:-http://jira-service:8002}"
OSIM_VERSION='{"rev":"dev","tag":"dev","timestamp":"1970-01-01T00:00:00Z"}'
OSIM_READONLY_MODE=${OSIM_READONLY_MODE:-false}
Expand All @@ -33,7 +34,8 @@ IFS= read -r -d '' OSIM_RUNTIME <<EOF || :
"bugzilla": "${OSIM_BACKENDS_BUGZILLA}",
"jira": "${OSIM_BACKENDS_JIRA}",
"errata": "${OSIM_BACKENDS_ERRATA}",
"jiraDisplay": "${OSIM_BACKENDS_JIRA_DISPLAY}"
"jiraDisplay": "${OSIM_BACKENDS_JIRA_DISPLAY}",
"mitre": "${OSIM_BACKENDS_MITRE}"
},
"osimVersion": ${OSIM_VERSION},
"readOnly": ${OSIM_READONLY_MODE}
Expand Down
23 changes: 23 additions & 0 deletions build/entrypoint.d/32-mitre-proxy.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
#!/bin/sh

# Skip creating proxy file if no proxies are configured
if [ -z "$OSIM_NGINX_PROXY_MITRE" ]; then
exit 0;
fi

# Get proxy certificate
curl --xattr "$OSIM_NGINX_PROXY_CA" -o /tmp/Proxy-CA.crt

# Ensure no trailing slash in variable, so no duplicate trailing slash is added in proxy_pass
OSIM_NGINX_PROXY_MITRE="${OSIM_NGINX_PROXY_MITRE%/}"

echo resolver "$(awk -v ORS=' ' '$1=="nameserver" {print $2}' /etc/resolv.conf)" ";" >/etc/nginx/conf.d/resolvers.conf

# Add MITRE reverse proxy endpoint
cat <<EOF >/tmp/osim-nginx-proxy.conf
location /proxy/mitre/ {
# Trailing slash in proxy_pass strips the location directive prefix from the downstream URL
proxy_pass ${OSIM_NGINX_PROXY_MITRE}/;
proxy_http_version 1.1;
}
EOF
1 change: 1 addition & 0 deletions src/stores/__tests__/osimRuntime.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ describe('osimRuntime', () => {
bugzilla: 'bugzilla',
jira: 'jira',
errata: 'errata',
mitre: 'mitre',
jiraDisplay: 'jiraDisplay',
osidbAuth: 'credentials',
},
Expand Down
2 changes: 2 additions & 0 deletions src/stores/osimRuntime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ const OsimRuntime = z.object({
jira: z.string(),
errata: z.string(),
jiraDisplay: z.string(),
mitre: z.string(),
}),
osimVersion: z.object({
rev: z.string(),
Expand All @@ -52,6 +53,7 @@ const runtime = ref<OsimRuntime>({
jira: 'http://jira-service:8002',
errata: 'http://errata-service:8003',
jiraDisplay: 'http://jira-service:8002',
mitre: 'http://mitre-service:8004',
},
osimVersion: { rev: 'dev', tag: 'dev', timestamp: '1970-01-01T00:00:00Z' },
error: 'error',
Expand Down

0 comments on commit 20eb135

Please sign in to comment.