blob: b67b6ef288df98f0e77458bf29321bdc0dce47b1 [file] [log] [blame]
#
# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements. See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License. You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
#
# -------------------------
# add X-Request-Id header
# -------------------------
set $requestId $http_x_request_id;
set_secure_random_alphanum $requestId_random 32;
set_if_empty $requestId $requestId_random;
add_header X-Request-Id $requestId;
proxy_set_header X-Request-Id $requestId;
# -----------
# X-Real-IP
# -----------
set $proxy_remote_addr $http_x_real_ip;
set_if_empty $proxy_remote_addr $remote_addr;
proxy_set_header X-Real-IP $proxy_remote_addr;
# -----------------
# X-Forwarded-For
# X-Forwarded-Host
# -----------------
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Host $host;
# -----------------
# X-Forwarded-Port
# -----------------
set $proxy_forwarded_port $http_x_forwarded_port;
set_if_empty $proxy_forwarded_port $server_port;
proxy_set_header X-Forwarded-Port $proxy_forwarded_port;
# ------------------
# X-Forwarded-Proto
# ------------------
set $proxy_forwarded_proto $http_x_forwarded_proto;
set_if_empty $proxy_forwarded_proto $scheme;
proxy_set_header X-forwarded-Proto $proxy_forwarded_proto;
# ---------------
# X-Gateway-Host
# ---------------
set_by_lua_block $gateway_host {
local host = os.getenv("HOST")
local port = os.getenv("PORT")
if host ~= nil and port ~= nil then
return host .. ":" .. port
end
}
add_header X-Gateway-Host $gateway_host;