Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

THREESCALE-10582 fix integration of upstream connection policy with camel policy #1443

Merged
merged 9 commits into from
Feb 8, 2024
Prev Previous commit
Next Next commit
small refactor
- skip_https_connect as request attribute
- http_proxy not used attribute http_backend removed
eguzki committed Feb 6, 2024

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit a1f600852f7ff5500271cfb731e4684943588b38
6 changes: 3 additions & 3 deletions gateway/src/apicast/http_proxy.lua
Original file line number Diff line number Diff line change
@@ -27,7 +27,6 @@ local DEFAULT_CHUNKSIZE = 32 * 1024

function _M.reset()
_M.resolver = resty_resolver
_M.http_backend = require('resty.http_ng.backend.resty')
_M.dns_resolution = 'apicast' -- can be set to 'proxy' to let proxy do the name resolution

return _M
@@ -147,10 +146,11 @@ local function forward_https_request(proxy_uri, uri, proxy_opts)
body = body,
proxy_uri = proxy_uri,
proxy_auth = opts.proxy_auth,
upstream_connection_opts = opts.upstream_connection_opts
upstream_connection_opts = opts.upstream_connection_opts,
skip_https_connect = opts.skip_https_connect
}

local httpc, err = http_proxy.new(request, opts.skip_https_connect)
local httpc, err = http_proxy.new(request)

if not httpc then
ngx.log(ngx.ERR, 'could not connect to proxy: ', proxy_uri, ' err: ', err)
7 changes: 4 additions & 3 deletions gateway/src/resty/http/proxy.lua
Original file line number Diff line number Diff line change
@@ -77,11 +77,12 @@ local function _connect_proxy_https(httpc, request, host, port)
return httpc
end

local function connect_proxy(httpc, request, skip_https_connect)
local function connect_proxy(httpc, request)
-- target server requires hostname not IP and DNS resolution is left to the proxy itself as specified in the RFC #7231
-- https://httpwg.org/specs/rfc7231.html#CONNECT
local uri = request.uri
local proxy_uri = request.proxy
local skip_https_connect = request.skip_https_connect

if proxy_uri.scheme ~= 'http' then
return nil, 'proxy connection supports only http'
@@ -131,7 +132,7 @@ local function find_proxy_url(request)
return request.proxy_uri or _M.find(uri)
end

local function connect(request, skip_https_connect)
local function connect(request)
request = request or { }
local opts = { timeouts = request.upstream_connection_opts }
local httpc = http.new(opts)
@@ -141,7 +142,7 @@ local function connect(request, skip_https_connect)
request.proxy = proxy_uri

if proxy_uri then
return connect_proxy(httpc, request, skip_https_connect)
return connect_proxy(httpc, request)
else
return connect_direct(httpc, request)
end