Skip to content

Commit a9df906

Browse files
clarify reference URLs
Co-Authored-By: SC-PUNDIT-BOT <[email protected]>
1 parent 6ad0c62 commit a9df906

File tree

3 files changed

+17
-15
lines changed

3 files changed

+17
-15
lines changed

auth-oidc-proxy/nginx/origin-template.conf

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
server {
22

33
listen 8080;
4-
server_name ${ORIGIN_APP_FQDN};
4+
server_name ${PROXY_APP_FQDN};
55
root /opt/app-root/src;
66

7-
location / {
7+
location / {
88
auth_request /auth;
99
error_page 401 = /auth/login;
10-
10+
1111
proxy_pass http://${ORIGIN_APP_NAME}.${CE_SUBDOMAIN}.svc.cluster.local;
1212
proxy_set_header Host ${ORIGIN_APP_NAME}.${CE_SUBDOMAIN}.svc.cluster.local;
1313
proxy_set_header X-Real-IP $remote_addr;
1414
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
1515
proxy_set_header X-Auth-Request-Redirect $request_uri;
1616
proxy_pass_request_headers on;
17-
17+
1818
# WebSocket support
1919
proxy_http_version 1.1;
2020
proxy_set_header Upgrade $http_upgrade;
@@ -29,7 +29,7 @@ server {
2929
proxy_set_header Content-Length "";
3030
proxy_set_header X-Original-URI $request_uri;
3131
proxy_pass_request_headers on;
32-
32+
3333
proxy_http_version 1.1;
3434
proxy_set_header Upgrade $http_upgrade;
3535
proxy_set_header Connection $connection_upgrade;

auth-oidc-proxy/nginx/start-nginx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ set -e
55
# Replace all "CE_SUBDOMAIN" in the config file with the Code Engine subdomain (k8s ns)
66
# see: https://www.baeldung.com/linux/nginx-config-environment-variables
77
echo "Performing environment variable substitutions ..."
8-
envsubst '\$ORIGIN_APP_FQDN \$ORIGIN_APP_NAME \$AUTH_APP_NAME \$CE_SUBDOMAIN' < /tmp/origin-template.conf > /opt/app-root/etc/nginx.d/origin.conf
8+
envsubst '\$PROXY_APP_FQDN \$ORIGIN_APP_NAME \$AUTH_APP_NAME \$CE_SUBDOMAIN' < /tmp/origin-template.conf > /opt/app-root/etc/nginx.d/origin.conf
99

1010
echo "Starting NGINX with the following config file '${NGINX_CONF_PATH}'"
1111
cat ${NGINX_CONF_PATH}

auth-oidc-proxy/run

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ function clean() {
7070
fi
7171

7272
ibmcloud resource group-delete $RESOURCE_GROUP_NAME --force 2>/dev/null
73-
73+
7474
echo "Done!"
7575
}
7676

@@ -79,7 +79,7 @@ function abortScript() {
7979
if [[ "${CLEANUP_ON_ERROR}" == true ]]; then
8080
clean
8181
else
82-
print_msg "\nSkipping deletion of the created IBM Cloud resources."
82+
print_msg "\nSkipping deletion of the created IBM Cloud resources."
8383
echo "$ ibmcloud resource service-instances --type all -g $RESOURCE_GROUP_NAME"
8484
ibmcloud resource service-instances --type all -g $RESOURCE_GROUP_NAME
8585
fi
@@ -158,13 +158,14 @@ if ! ibmcloud ce app get --name $CE_APP_ORIGIN >/dev/null 2>&1; then
158158
print_error "Code Engine origin app create/update failed!"
159159
abortScript
160160
fi
161-
else
161+
else
162162
echo "Done!"
163163
fi
164164

165165
ROOT_DOMAIN=.${CE_PROJECT_NAMESPACE}.${CE_PROJECT_DOMAIN}
166166
FQDN_ORIGIN_APP=${CE_APP_ORIGIN}${ROOT_DOMAIN}
167167
URL_ORIGIN_APP=https://${FQDN_ORIGIN_APP}
168+
USER_ACCESS_URL=${URL_ORIGIN_APP}
168169

169170
# ================================================
170171
# OPTIONAL: Configuring Authn and Authz
@@ -194,8 +195,9 @@ else
194195
echo "Yes! Setting up the authentication and the proxy apps"
195196

196197
URL_AUTH_APP=https://${CE_APP_AUTH}${ROOT_DOMAIN}
197-
FQDN_ORIGIN_APP=${CE_APP_PROXY}${ROOT_DOMAIN}
198-
URL_ORIGIN_APP=https://${FQDN_ORIGIN_APP}
198+
FQDN_PROXY_APP=${CE_APP_PROXY}${ROOT_DOMAIN}
199+
URL_PROXY_APP=https://${FQDN_PROXY_APP}
200+
USER_ACCESS_URL=${URL_PROXY_APP}
199201

200202
authapp_op_create_or_update=update
201203
if ! ibmcloud ce app get --name $CE_APP_AUTH >/dev/null 2>&1; then
@@ -216,7 +218,7 @@ else
216218
--port 8080 \
217219
--env-from-secret $CE_SECRET_AUTH \
218220
--env COOKIE_DOMAIN="$ROOT_DOMAIN" \
219-
--env REDIRECT_URL="$URL_ORIGIN_APP" \
221+
--env REDIRECT_URL="$URL_PROXY_APP" \
220222
--env OIDC_REDIRECT_URL="${URL_AUTH_APP}/auth/callback"
221223
if [ $? -ne 0 ]; then
222224
print_error "Code Engine auth app create/update failed!"
@@ -238,7 +240,7 @@ else
238240
--cpu 1 \
239241
--memory 2G \
240242
--scale-down-delay 600 \
241-
--env ORIGIN_APP_FQDN=$FQDN_ORIGIN_APP \
243+
--env PROXY_APP_FQDN=$FQDN_PROXY_APP \
242244
--env ORIGIN_APP_NAME=$CE_APP_ORIGIN \
243245
--env AUTH_APP_NAME=$CE_APP_AUTH \
244246
--port 8080
@@ -260,9 +262,9 @@ ibmcloud ce app list
260262
if [[ "${CLEANUP_ON_SUCCESS}" == true ]]; then
261263
print_msg "\nCleaning up the created IBM Cloud resources ..."
262264
clean
263-
else
265+
else
264266
print_msg "\nFollowing commands can be used to further play around with the sample setup:"
265-
echo "1. Open the browser and type '$URL_ORIGIN_APP' to access the origin app"
267+
echo "1. Open the browser and type '$USER_ACCESS_URL' to access the origin app"
266268
echo "2. Tear down the sample setup: './run clean'"
267269
fi
268270

0 commit comments

Comments
 (0)