forked from 3scale/APIcast
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request 3scale#1408 from tkan145/THREESCALE-9542-buffering…
…-policy [THREESCALE-9542] Part 1: buffering policy
- Loading branch information
Showing
10 changed files
with
378 additions
and
67 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
#{% capture proxy_cache_valid %} | ||
#{#} proxy_cache $cache_zone; | ||
#{#} proxy_cache_key $scheme$request_method$proxy_host$request_uri$service_id; | ||
#{#} proxy_no_cache $cache_request; | ||
#{#} proxy_cache_valid {{ env.APICAST_CACHE_STATUS_CODES | default: '200 302'}} {{ env.APICAST_CACHE_MAX_TIME | default: '1m' }}; | ||
#{% endcapture %} | ||
#{{ proxy_cache_valid | replace: "#{#}", "" }} | ||
# | ||
|
||
#{% if opentelemetry != empty %} | ||
# {% capture opentelemetry_propagate_directive %} | ||
#{#} opentelemetry_propagate; | ||
# {% endcapture %} | ||
# {{ opentelemetry_propagate_directive | replace: "#{#}", "" }} | ||
#{% endif %} | ||
|
||
proxy_pass $proxy_pass; | ||
|
||
proxy_http_version 1.1; | ||
|
||
proxy_set_header X-Real-IP $remote_addr; | ||
proxy_set_header Host $http_host; | ||
proxy_set_header X-3scale-proxy-secret-token $secret_token; | ||
proxy_set_header X-3scale-debug ""; | ||
proxy_set_header Connection $upstream_connection_header; | ||
proxy_set_header Upgrade $upstream_upgrade_header; | ||
|
||
# This is a bit tricky. It uses liquid to set a SSL client certificate. In | ||
# NGINX, all this is not executed as it is commented with '#'. However, in | ||
# Liquid, all this will be evaluated. As a result, the following directives | ||
# are set optionally: proxy_ssl_certificate, proxy_ssl_certificate_key, | ||
# proxy_ssl_session_reuse, and proxy_ssl_password_file. | ||
|
||
# {% if proxy_ssl_certificate != empty and proxy_ssl_certificate_key != empty %} | ||
# {% capture proxy_ssl %} | ||
#{#} proxy_ssl_certificate {{ proxy_ssl_certificate }}; | ||
#{#} proxy_ssl_certificate_key {{ proxy_ssl_certificate_key }}; | ||
# {% endcapture %} | ||
# {{ proxy_ssl | replace: "#{#}", "" }} | ||
# | ||
# {% if proxy_ssl_password_file != empty %} | ||
# {% capture proxy_ssl %} | ||
#{#} proxy_ssl_password_file {{ proxy_ssl_password_file }}; | ||
# {% endcapture %} | ||
# {{ proxy_ssl | replace: "#{#}", "" }} | ||
# {% endif %} | ||
# | ||
# {% if proxy_ssl_session_reuse != empty %} | ||
# {% capture proxy_ssl %} | ||
#{#} proxy_ssl_session_reuse {{ proxy_ssl_session_reuse }}; | ||
# {% endcapture %} | ||
# {{ proxy_ssl | replace: "#{#}", "" }} | ||
# {% endif %} | ||
# {% endif %} | ||
|
||
# When 'upstream_retry_cases' is empty, apply the same default as NGINX. | ||
# If the proxy_next_upstream directive is not declared, the retry policy | ||
# will never retry. | ||
# {% if upstream_retry_cases != empty %} | ||
# {% capture proxy_next_upstream %} | ||
#{#} proxy_next_upstream {{ upstream_retry_cases }}; | ||
# {% endcapture %} | ||
# {{ proxy_next_upstream | replace: "#{#}", "" }} | ||
# {% else %} | ||
# proxy_next_upstream error timeout; | ||
# {% endif %} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
# APICast Request Unbuffered | ||
|
||
This policy allows to disable request buffering | ||
|
||
## Example configuration | ||
|
||
``` | ||
{ | ||
"name": "request_unbuffered", | ||
"version": "builtin", | ||
"configuration": {} | ||
} | ||
``` | ||
|
13 changes: 13 additions & 0 deletions
13
gateway/src/apicast/policy/request_unbuffered/apicast-policy.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"$schema": "http://apicast.io/policy-v1/schema#manifest#", | ||
"name": "Request Unbuffered", | ||
"summary": "Disable request buffering", | ||
"description": [ | ||
"Disable request buffering. This is useful when proxying big payloads with HTTP/1.1 chunked encoding" | ||
], | ||
"version": "builtin", | ||
"configuration": { | ||
"type": "object", | ||
"properties": {} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
return require('request_unbuffered') |
22 changes: 22 additions & 0 deletions
22
gateway/src/apicast/policy/request_unbuffered/request_unbuffered.lua
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
-- Request Unbuffered policy | ||
-- This policy will disable request buffering | ||
|
||
local policy = require('apicast.policy') | ||
local _M = policy.new('request_unbuffered') | ||
|
||
local new = _M.new | ||
|
||
--- Initialize a buffering | ||
-- @tparam[opt] table config Policy configuration. | ||
function _M.new(config) | ||
local self = new(config) | ||
return self | ||
end | ||
|
||
function _M:export() | ||
return { | ||
request_unbuffered = true, | ||
} | ||
end | ||
|
||
return _M |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.