Skip to content

Commit

Permalink
URL redirection from "k8s.io/internal" as experiment
Browse files Browse the repository at this point in the history
Signed-off-by: Davanum Srinivas <davanum@gmail.com>
  • Loading branch information
dims committed Feb 4, 2022
1 parent 79aa001 commit a75d64e
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions apps/k8s-io/configmap-nginx.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,34 @@ data:
return 200 'ok';
}
location ~ ^/internal/(?<repo>[^/]*)(?<subpath>/.*)?$ {
# $https is set to 'on' when connecting to nginx via HTTPS directly.
set $https_status $https;
if ($http_x_forwarded_proto = 'https') {
set $https_status 'on';
}
# Upgrade HTTP to HTTPS.
if ($https_status != 'on') {
return 301 https://$host$request_uri;
}
if ($arg_go-get = "1") {
# This is a go-get operation.
return 200 '
<html><head>
<meta name="go-import"
content="k8s.io/internal/$repo
git https://github.com/k8s-internal/$repo">
<meta name="go-source"
content="k8s.io/internal/$repo
https://github.com/k8s-internal/$repo
https://github.com/k8s-internal/$repo/tree/master{/dir}
https://github.com/k8s-internal/$repo/blob/master{/dir}/{file}#L{line}">
</head></html>
';
}
}
location ~ ^/(?<repo>[^/]*)(?<subpath>/.*)?$ {
# $https is set to 'on' when connecting to nginx via HTTPS directly.
set $https_status $https;
Expand Down

0 comments on commit a75d64e

Please sign in to comment.