Handle backendURLs without protocol (#103)

diff --git a/api-gateway-config/conf.d/api_gateway_logging.conf b/api-gateway-config/conf.d/api_gateway_logging.conf
index f2084dc..5bd8786 100644
--- a/api-gateway-config/conf.d/api_gateway_logging.conf
+++ b/api-gateway-config/conf.d/api_gateway_logging.conf
@@ -20,12 +20,12 @@
 # * DEALINGS IN THE SOFTWARE.
 # *
 # */
-log_format  main  '$remote_addr - $remote_user [$time_local] request="$request" '
+log_format  main  '$remote_addr - remote_user="$remote_user" [$time_local] request="$request" '
                   'status=$status bbs=$body_bytes_sent rl=$request_length rt=$request_time hr="$http_referer" '
                   'ua="$http_user_agent" xfwdf="$http_x_forwarded_for"';
 
 
-log_format  platform  '$remote_addr - $remote_user [$time_local] request="$request" '
+log_format  platform  '$remote_addr - remote_user="$remote_user" [$time_local] request="$request" '
                       'status=$status bbs=$body_bytes_sent rl=$request_length rt=$request_time hr="$http_referer" '
                       'ua="$http_user_agent" xfwdf="$http_x_forwarded_for" '
                       'upadd="$upstream_addr" upstat=$upstream_status uprt=$upstream_response_time '
diff --git a/api-gateway-config/scripts/lua/lib/redis.lua b/api-gateway-config/scripts/lua/lib/redis.lua
index 8a4b47c..41eeb67 100644
--- a/api-gateway-config/scripts/lua/lib/redis.lua
+++ b/api-gateway-config/scripts/lua/lib/redis.lua
@@ -104,8 +104,9 @@
     -- Delete all resources for the existingAPI
     local basePath = existingAPI.basePath:sub(2)
     for path, v in pairs(existingAPI.resources) do
-      local gatewayPath = utils.concatStrings({basePath, ngx.escape_uri(path)})
-      local redisKey = utils.concatStrings({"resources:", existingAPI.tenantId, ":", ngx.unescape_uri(gatewayPath)})
+      local gatewayPath = ngx.unescape_uri(utils.concatStrings({basePath, ngx.escape_uri(path)}))
+      gatewayPath = gatewayPath:sub(1,1) == "/" and gatewayPath:sub(2) or gatewayPath
+      local redisKey = utils.concatStrings({"resources:", existingAPI.tenantId, ":", gatewayPath})
       _M.deleteResource(red, redisKey, REDIS_FIELD)
     end
   end
diff --git a/api-gateway-config/scripts/lua/routing.lua b/api-gateway-config/scripts/lua/routing.lua
index 033bc96..3ff4bdf 100644
--- a/api-gateway-config/scripts/lua/routing.lua
+++ b/api-gateway-config/scripts/lua/routing.lua
@@ -59,10 +59,15 @@
       end
       -- Parse backend url
       local u = url.parse(opFields.backendUrl)
+      -- add http:// if no protocol is specified
+      if u.scheme == nil then
+        u = url.parse(utils.concatStrings({'http://', opFields.backendUrl}))
+      end
       ngx.req.set_uri(getUriPath(u.path))
       ngx.var.backendUrl = opFields.backendUrl
-      -- Set upstream - add port if it's in the backendURL
+      -- Set upstream
       local upstream = utils.concatStrings({u.scheme, '://', u.host})
+      -- add port if it's in the backendURL
       if u.port ~= nil and u.port ~= '' then
         upstream = utils.concatStrings({upstream, ':', u.port})
       end