Home:ALL Converter>How do I send http requests to a Unix socket?

How do I send http requests to a Unix socket?

Ask Time:2019-10-12T01:53:15         Author:user2490003

Json Formatter

I have an nginx config that passes incoming requests to a local unix socket that's specifically listening for incoming requests

(If you're curious, this happens to be a Rails app running puma, but the question is generally applicable)

upstream app {
  server unix:/var/www/example.com/volumes/tmp/sockets/puma.sock fail_timeout=0;
}

server {

  listen              443 ssl;
  server_name         example.com;

  # Forward incoming requests to the socket
  location @app {
    proxy_pass http://app;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header Host $http_host;
    proxy_redirect off;
  }

  # ...
}

If I am logged into the local machine where this app is running, how do I send http requests to this Unix socket?

I can't seem to do -

curl unix://%2Fvar%2Fwww%2Fexample.com%2Fvolumes%2Ftmp%2Fsockets%2Fpuma.sock
curl: (1) Protocol "unix" not supported or disabled in libcurl

Author:user2490003,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/58346296/how-do-i-send-http-requests-to-a-unix-socket
yy