You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@openwhisk.apache.org by GitBox <gi...@apache.org> on 2018/03/10 02:47:50 UTC

[GitHub] mhamann closed pull request #281: Add x-forwarded-url to request headers

mhamann closed pull request #281: Add x-forwarded-url to request headers
URL: https://github.com/apache/incubator-openwhisk-apigateway/pull/281
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/scripts/lua/routing.lua b/scripts/lua/routing.lua
index 6d20c61..445d08e 100644
--- a/scripts/lua/routing.lua
+++ b/scripts/lua/routing.lua
@@ -87,6 +87,17 @@ function _M.processCall(dataStore)
       end
       -- Set backend upstream and uri
       backendRouting.setRoute(opFields.backendUrl, gatewayPath)
+      -- Set gateway url as request header
+      local requestScheme = ngx.req.get_headers()["X-Forwarded-Proto"]
+      if requestScheme == nil or requestScheme == "" then
+        requestScheme = ngx.var.scheme
+      end
+      local requestUrl = utils.concatStrings({requestScheme, "://", ngx.var.host})
+      local prefix = ngx.req.get_headers()["X-Forwarded-Prefix"]
+      if prefix ~= nil and prefix ~= "" then
+        requestUrl = utils.concatStrings({requestUrl, prefix})
+      end
+      ngx.req.set_header("X-Forwarded-Url", utils.concatStrings({requestUrl, ngx.var.request_uri}))
       -- Parse policies
       if opFields.policies ~= nil then
         parsePolicies(dataStore, opFields.policies, key)


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services