Repository: rclone/rclone (language: go)

Issue:
Cannot connect to rcd listening on Unix socket: "no Host in request URL"
#### The associated forum post URL from `https://forum.rclone.org`

N/A. I tried to register, but the confirmation email isn't arriving. In any case, I think this is a bug. Or if I'm doing it wrong, it's probably still an omission in the documentation.

#### What is the problem you are having with rclone?

In one terminal, start rcd listening on a Unix domain socket:

```
$ rclone rcd --rc-addr unix:///tmp/rclone.socket
```

In another, try to connect to it. This doesn't work:

```
$ rclone rc --url /tmp/rclone.socket rc/noop
{
	"error": "connection failed: Post \"http:///tmp/rclone.socket/rc/noop\": http: no Host in request URL",
	"path": "rc/noop",
	"status": 503
}
2024/12/17 17:20:11 NOTICE: Failed to rc: connection failed: Post "http:///tmp/rclone.socket/rc/noop": http: no Host in request URL
```

(I initially tried `--url unix:///tmp/rclone.socket` but it mangles the URL to `http://unix///tmp/rclone.socket/rc/noop`, which is a separate issue.)

I can reproduce it with socat as well:

```
$ socat - UNIX-CONNECT:/tmp/rclone.socket 
GET / HTTP/1.1

HTTP/1.1 400 Bad Request: missing required Host header
Content-Type: text/plain; charset=utf-8
Connection: close

400 Bad Request: missing required Host header
```

When I do give a `Host` header, the request succeeds:

```
$ socat - UNIX-CONNECT:/tmp/rclone.socket 
GET / HTTP/1.1
Host: localhost

HTTP/1.1 404 Not Found
Accept-Ranges: bytes
Content-Type: text/plain; charset=utf-8
Server: rclone/v1.68.2
X-Content-Type-Options: nosniff
Date: Tue, 17 Dec 2024 16:16:33 GMT
Content-Length: 10

Not Found
```

#### What is your rclone version (output from `rclone version`)

```
rclone v1.68.2
- os/version: arch (64 bit)
- os/kernel: 6.11.6-arch1-1 (x86_64)
- os/type: linux
- os/arch: amd64
- go/version: go1.23.3
- go/linking: dynamic
- go/tags: none
```

#### Which OS you are using and how many bits (e.g. Windows 7, 64 bit)

Arch Linux x86_64

#### Which cloud storage system are you using? (e.g. Google Drive)

N/A

#### The command you were trying to run (e.g. `rclone copy /tmp remote:tmp`)

```
$ rclone rc --url /tmp/rclone.socket rc/noop -vv
```

#### A log from the command with the `-vv` flag (e.g. output from `rclone -vv copy /tmp remote:tmp`)

```
2024/12/17 17:15:17 DEBUG : rclone: Version "v1.68.2" starting with parameters ["rclone" "rc" "--url" "/tmp/rclone.socket" "rc/noop" "-vv"]
{
	"error": "connection failed: Post \"http:///tmp/rclone.socket/rc/noop\": http: no Host in request URL",
	"path": "rc/noop",
	"status": 503
}
2024/12/17 17:15:17 DEBUG : 4 go routines active
2024/12/17 17:15:17 NOTICE: Failed to rc: connection failed: Post "http:///tmp/rclone.socket/rc/noop": http: no Host in request URL
```

#### How to use GitHub

* Please use the 👍 [reaction](https://blog.github.com/2016-03-10-add-reactions-to-pull-requests-issues-and-comments/) to show that you are affected by the same issue.
* Please don't comment if you have no relevant information to add. It's just extra noise for everyone subscribed to this issue.
* Subscribe to receive notifications on status change and new comments.


Discussion / hints:
Try this

    rclone rc --unix-socket /tmp/rclone.socket core/version

Note that as we are doing HTTP over unix sockets, we still need the URL, we just ignore the host part of it. There isn't a standard way of expressing a http + unix socket path + URL path in a URL string so we decided to have an additional parameter.

This is documented here https://rclone.org/commands/rclone_rc/ but not here https://rclone.org/rc/  which is probably where you looked so we could improve that.

Fix patch:
diff --git a/docs/content/rc.md b/docs/content/rc.md
index cc3b8329f72bc..e16055e32da86 100644
--- a/docs/content/rc.md
+++ b/docs/content/rc.md
@@ -180,7 +180,7 @@ User-specified template.
 Rclone itself implements the remote control protocol in its `rclone
 rc` command.
 
-You can use it like this
+You can use it like this:
 
 ```
 $ rclone rc rc/noop param1=one param2=two
@@ -190,8 +190,23 @@ $ rclone rc rc/noop param1=one param2=two
 }
 ```
 
-Run `rclone rc` on its own to see the help for the installed remote
-control commands.
+If the remote is running on a different URL than the default
+`http://localhost:5572/`, use the `--url` option to specify it:
+
+```
+$ rclone rc --url http://some.remote:1234/ rc/noop
+```
+
+Or, if the remote is listening on a Unix socket, use the `--unix-socket` option
+instead:
+
+```
+$ rclone rc --unix-socket /tmp/rclone.sock rc/noop
+```
+
+Run `rclone rc` on its own, without any commands, to see the help for the
+installed remote control commands. Note that this also needs to connect to the
+remote server.
 
 ## JSON input
 


Test patch: