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

bug: batch-requests plugin: "connect to apisix failed: missing the port number" when connecting via unix socket #11781

Open
ShaunMaher opened this issue Nov 26, 2024 · 0 comments · May be fixed by #11782
Labels
bug Something isn't working plugin

Comments

@ShaunMaher
Copy link

Current Behavior

If you configure Nginx to listen on a unix socket:

nginx_config:
  http_server_configuration_snippet: |
    listen unix:/run/sockets/apisix_http;

And then make a request that is handled by the batch-requests plugin, you get the following error:

connect to apisix failed: missing the port number

This is because the batch-requests plugin uses the ngx.var.server_port variable when setting up the internal request, assuming that it is populated with a port number. If the client connection came over a unix listening socket, ngx.var.server_port is a zero length string.

Expected Behavior

I get that unix sockets are probably an edge case but it would be nice if this worked.

I will submit a PR shortly with my modified batch-requests.lua that checks for this condition and then gets the server_port from the node_listen property of the APISIX configuration.

Error Logs

No response

Steps to Reproduce

  • Use the latest docker image
  • Configure nginx (via apisix config.yml) to listen on a unix socket:
nginx_config:
  http_server_configuration_snippet: |
    listen unix:/run/sockets/apisix_http;
  • Configure the batch-requests plugin
  • Issue a batch-request via the unix socket:
    curl --unix-socket /run/sockets/apisix_http http://127.0.0.1:9080/your_url --data '{}'

Environment

  • APISIX version: 3.11.0
  • Operating system:
  • OpenResty / Nginx version: openresty/1.25.3.2
  • etcd version: Using Standalone mode
  • APISIX Dashboard version, if relevant: Dashboard not in use
  • Plugin runner version, for issues related to plugin runners: N/A
  • LuaRocks version, for installation issues (run luarocks --version): N/A
ShaunMaher pushed a commit to ShaunMaher/apisix that referenced this issue Nov 26, 2024
@dosubot dosubot bot added bug Something isn't working plugin labels Nov 26, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working plugin
Projects
Status: 📋 Backlog
Development

Successfully merging a pull request may close this issue.

1 participant