-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
fix(aws-lambda) proxy correctly with lua-resty-http #8406
Conversation
lua-resty-http only supports http connections to the proxy, regardless of request scheme
This config parameter is not used anywhere.
@@ -75,6 +75,7 @@ return { | |||
type = "boolean", | |||
default = false, | |||
} }, | |||
-- TODO: remove proxy_scheme in Kong 3.0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@bungle We should explore a "deprecated = true" property on the schema to manage these programmatically.
listen 13128; | ||
|
||
content_by_lua_block { | ||
require("spec.fixtures.forward-proxy-server").connect() |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like that
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Fix some bugs and warts in the aws-lambda plugin: * Fix broken proxying by always using `https_proxy` with resty.http * Deprecate `proxy_scheme` config param Some minimal test coverage for proxying was added, and some defunct test cases were removed.
Fix some bugs and warts in the aws-lambda plugin: * Fix broken proxying by always using `https_proxy` with resty.http * Deprecate `proxy_scheme` config param Some minimal test coverage for proxying was added, and some defunct test cases were removed.
Fix some bugs and warts in the aws-lambda plugin: * Fix broken proxying by always using `https_proxy` with resty.http * Deprecate `proxy_scheme` config param Some minimal test coverage for proxying was added, and some defunct test cases were removed.
Fix some bugs and warts in the aws-lambda plugin: * Fix broken proxying by always using `https_proxy` with resty.http * Deprecate `proxy_scheme` config param Some minimal test coverage for proxying was added, and some defunct test cases were removed.
Summary
The aws-lambda plugin currently mishandles user proxy configuration, passing
proxy_opts.http_proxy
toresty.http
when it ought to be passingproxy_opts.https_proxy
(since the request to AWS lambda is always https).This PR remedies that problem along with a couple other shortcomings surrounding the config schema:
proxy_scheme
param is unused and is not needed with the current implementation (proxy_url
expects a full url with scheme). This PR deprecates it, logging a warning that it will be removed in Kong 3.0.proxy_url
to ensure only http is used.Testing
This plugin used to ship with it's own specialized http connect code (and tests). This is not used anymore, so the associated tests (
spec/03-plugins/27-aws-lambda/50-http-proxy_spec.lua
) have been removed, as they do not test anything specific to this plugin or its code.The access handler tests didn't have any coverage for instances using an http proxy, so I sought to add one, which was a little bit more involved of a chore than I expected. The repo's CI pipeline stuff includes a squid container (previously used for the aforementioned http connect tests), but using this in tests is a royal pain:
127.0.0.1
for all targets without requiring the container to run in host networking mode.So I ditched squid and wrote a minimal TCP server that implements CONNECT (
spec/fixtures/forward-proxy-server.lua
). It's not awesome, but it gets the job done.Result: the test coverage for aws-lambda+http proxy still leaves much to be desired, but this is a step in the right direction.
Full changelog
Issue reference
Fix #8317