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

return the same status code 403 as nginx does to refuse CONNECT method #251

Merged
merged 2 commits into from Feb 9, 2023

Conversation

chobits
Copy link
Owner

@chobits chobits commented Feb 7, 2023

If proxy_connect module is not enabled, the server will return a 405 status code instead of 400.

…ethod

If proxy_connect module is not enabled, the server will return a 405 status code instead of 400.
@@ -2342,7 +2342,7 @@ ngx_http_proxy_connect_post_read_handler(ngx_http_request_t *r)
if (!pclcf->accept_connect) {
ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
"proxy_connect: client sent connect method");
return NGX_HTTP_BAD_REQUEST;
return NGX_HTTP_NOT_ALLOWED;
Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

refer to nginx core logic:

ngx_http_process_request_header(ngx_http_request_t *r)
{
....

    if (r->method == NGX_HTTP_CONNECT) {
        ngx_log_error(NGX_LOG_INFO, r->connection->log, 0,
                      "client sent CONNECT method");
        ngx_http_finalize_request(r, NGX_HTTP_NOT_ALLOWED);
        return NGX_ERROR;
    }

...
}

@@ -57,6 +57,7 @@ jobs:
pwd
git clone https://github.com/openresty/lua-resty-core.git
cd lua-resty-core
git checkout d2179dbcb3d6d77127462cadd40cca103d89a52a
Copy link
Owner Author

@chobits chobits Feb 7, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

try to fix error in github workflow

/opt/nginx/lib/lua/resty/core/base.lua:24: ngx_http_lua_module 0.10.23 required) in /tmp/nginx-test-LEG22dEa9Q/nginx.conf:93
nginx: [alert] failed to load the 'resty.core' module (https://github.com/openresty/lua-resty-core); ensure you are using an OpenResty release from https://openresty.org/en/download.html (reason: /opt/nginx/lib/lua/resty/core/base.lua:24: ngx_http_lua_module 0.10.23 required) in /tmp/nginx-test-LEG22dEa9Q/nginx.conf:93
Can't start nginx at /home/runner/work/ngx_http_proxy_connect_module/ngx_http_proxy_connect_module/nginx/../nginx-tests/lib/Test/Nginx.pm line 350.

@chobits chobits merged commit ed4b9cf into master Feb 9, 2023
@chobits chobits changed the title make it return the same status code as nginx does to refuse CONNECT method return the same status code 403 as nginx does to refuse CONNECT method Jun 13, 2023
@chobits chobits added this to the v0.0.5 milestone Jun 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant