3 Copyright (C) 2016 ZTE, Inc. and others. All rights reserved. (ZTE)
5 Licensed under the Apache License, Version 2.0 (the "License");
6 you may not use this file except in compliance with the License.
7 You may obtain a copy of the License at
9 http://www.apache.org/licenses/LICENSE-2.0
11 Unless required by applicable law or agreed to in writing, software
12 distributed under the License is distributed on an "AS IS" BASIS,
13 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14 See the License for the specific language governing permissions and
15 limitations under the License.
19 local BasePlugin = require "plugins.base_plugin"
20 local msbConf = require('conf.msbinit')
21 local log_util = require('lib.utils.log_util')
22 local log = log_util.log
24 local RedirectTransformerPluginHandler = BasePlugin:extend()
26 function RedirectTransformerPluginHandler:new()
27 RedirectTransformerPluginHandler.super.new(self, "redirect-transformer-plugin")
30 function RedirectTransformerPluginHandler:header_filter()
31 RedirectTransformerPluginHandler.super.header_filter(self)
32 local originloc = ngx.header.Location
34 local newloc = ngx.re.sub(originloc, "^(https|http)(.*)", ngx.var.scheme.."$2", "oi")
35 ngx.header["Location"] = newloc
36 log("origin Location:",originloc)
37 log("req scheme:",ngx.var.scheme)
38 log("new Location:",newloc)
42 return RedirectTransformerPluginHandler