diff options
author | paulrbr-fl <43074087+paulrbr-fl@users.noreply.github.com> | 2020-01-02 16:25:37 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-01-02 16:25:37 +0100 |
commit | 25250c8c24a3c0b32c92eee5552ad7156115f03c (patch) | |
tree | 02c178a19be0e233813600531c85ef7ad5e4c51c /dhall/server/service/plugin/http2httpsRedirect.dhall | |
parent | 027a2fa61a6044b2e967b29195312e4d98a96078 (diff) | |
parent | a3c4b3d5444e5d79afbd823a9acc12220a91f41f (diff) | |
download | ansible-kong-app-25250c8c24a3c0b32c92eee5552ad7156115f03c.tar.gz ansible-kong-app-25250c8c24a3c0b32c92eee5552ad7156115f03c.tar.zst ansible-kong-app-25250c8c24a3c0b32c92eee5552ad7156115f03c.zip |
Merge pull request #18 from paulrbr-fl/pre-function-pluginsv0.30
config(dhall): add a pre-function lua definition for HTTPS redirects
Diffstat (limited to 'dhall/server/service/plugin/http2httpsRedirect.dhall')
-rw-r--r-- | dhall/server/service/plugin/http2httpsRedirect.dhall | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/dhall/server/service/plugin/http2httpsRedirect.dhall b/dhall/server/service/plugin/http2httpsRedirect.dhall new file mode 100644 index 0000000..faa6d79 --- /dev/null +++ b/dhall/server/service/plugin/http2httpsRedirect.dhall | |||
@@ -0,0 +1,15 @@ | |||
1 | let mkPreFunction = ./mkPreFunction.dhall | ||
2 | |||
3 | let luaRedirect = | ||
4 | '' | ||
5 | local scheme = kong.request.get_scheme() | ||
6 | if scheme == "http" then | ||
7 | local host = kong.request.get_host() | ||
8 | local query = kong.request.get_path_with_query() | ||
9 | local url = "https://" .. host ..query | ||
10 | kong.response.set_header("Location", url) | ||
11 | return kong.response.exit(301, url) | ||
12 | end | ||
13 | '' | ||
14 | |||
15 | in mkPreFunction [ luaRedirect ] | ||