Skip to content

Commit 4c14380

Browse files
committed
feat: parameterize SIGN_IN_URL
1 parent d65a06f commit 4c14380

File tree

5 files changed

+41
-4
lines changed

5 files changed

+41
-4
lines changed

.env

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
SIGN_IN_URL='#'

401.html.template

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
<!DOCTYPE html>
2+
<html>
3+
<head>
4+
<title>MMLI: Unauthorized</title>
5+
<script src="/env.js"></script>
6+
</head>
7+
<body>
8+
9+
<p>Unauthorized</p>
10+
11+
<a id='signInLink' href='#'>Sign In</a>
12+
13+
<script>
14+
var origin = window.location.href;
15+
var rd = encodeURIComponent(origin);
16+
var href = `${SIGN_IN_URL}?rd=` + rd;
17+
document.getElementById('signInLink').href = href;
18+
window.location.href = href;
19+
</script>
20+
21+
</body>
22+
</html>

Dockerfile

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,14 @@
1-
FROM nginxinc/nginx-unprivileged
1+
FROM nginx:1
22

3-
COPY . /usr/share/nginx/html/
3+
# Enable built-in interpolation of templates
4+
ENV NGINX_ENVSUBST_TEMPLATE_DIR=/usr/share/nginx/templates \
5+
NGINX_ENVSUBST_OUTPUT_DIR=/usr/share/nginx/html
6+
7+
# Define variables that will be interpolated
8+
ENV SIGN_IN_URL='#'
9+
10+
# For templated HTML
11+
COPY *.template ${NGINX_ENVSUBST_TEMPLATE_DIR}/
12+
13+
# For static HTML
14+
#COPY *.html ${NGINX_ENVSUBST_OUTPUT_DIR}/

docker-compose.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
version: '3.9'
2-
31
services:
42
nginx-custom-errors:
53
container_name: 'nginx-custom-errors'
64
image: 'ndslabs/custom-errors'
5+
env_file:
6+
- .env
77
build:
88
context: .
99
ports:

env.js.template

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
window.env = {
2+
"SIGN_IN_URL": "${SIGN_IN_URL}"
3+
}

0 commit comments

Comments
 (0)