| #/* |
| # * Copyright (c) 2012 Adobe Systems Incorporated. All rights reserved. |
| # * |
| # * Permission is hereby granted, free of charge, to any person obtaining a |
| # * copy of this software and associated documentation files (the "Software"), |
| # * to deal in the Software without restriction, including without limitation |
| # * the rights to use, copy, modify, merge, publish, distribute, sublicense, |
| # * and/or sell copies of the Software, and to permit persons to whom the |
| # * Software is furnished to do so, subject to the following conditions: |
| # * |
| # * The above copyright notice and this permission notice shall be included in |
| # * all copies or substantial portions of the Software. |
| # * |
| # * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
| # * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
| # * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
| # * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
| # * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING |
| # * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER |
| # * DEALINGS IN THE SOFTWARE. |
| # * |
| # */ |
| # ------------------------- |
| # 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; |