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

Missing request body despite echo_read_request_body use #117

Open
jakubgs opened this issue Sep 16, 2024 · 2 comments
Open

Missing request body despite echo_read_request_body use #117

jakubgs opened this issue Sep 16, 2024 · 2 comments

Comments

@jakubgs
Copy link

jakubgs commented Sep 16, 2024

I'm using the echo modules to send the same GitHub webhook request to two backends that needs to receive it. I spit them using echo_subrequest_async, but when I do there is no request body. I have tried using both -b $request_body and -f $request_body_file with the same effect:

location = /webhook {
  echo_read_request_body;
  echo_subrequest_async POST /webhook_backend_0 -f $request_body_file;
  echo_subrequest_async POST /webhook_backend_1 -f $request_body_file;
}
location = /webhook_backend_0 {
  proxy_pass http://10.10.0.10:8080/webhook;
}
location = /webhook_backend_1 {
  proxy_pass http://10.10.0.20:8080/webhook;
}

When using -f $request_body_file I managed to catch this in Nginx errors:

open() "/var/lib/nginx/body/0000005084" failed (2: No such file or directory), client: 1.2.3.4, server: example.org, request: "POST /webhook HTTP/1.1", host: "example.org"

Which indicates that the request body is indeed missing, but as far as I know it is not, since GitHub does send it.

This suggests a bug in the echo module.

@jakubgs
Copy link
Author

jakubgs commented Sep 16, 2024

I have attempted to mitigate this issue by adding echo_sleep 0.001 and echo_blocking_sleep 0.001 in order to force the body to be loaded, and it does appear to slightly decrease the instances of missing body in Webhook request.

@jakubgs
Copy link
Author

jakubgs commented Sep 16, 2024

I'm actually a bit confused as to what's the correct way of doing this. I see at least 6 options:

  • Use $request_body with -b for echo_subrequest_async.
  • Use $request_body with -b for echo_subrequest_async with echo_read_request_body.
  • Use $request_body_file with -f for echo_subrequest_async.
  • Use $request_body_file with -f for echo_subrequest_async with echo_read_request_body.
  • Use $echo_request_body with -b for echo_subrequest_async.
  • Use $echo_request_body with -b for echo_subrequest_async with echo_read_request_body.

I'm sure there's more combinations. No idea which is correct. Seem to me like none work correctly.

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

No branches or pull requests

1 participant