Rclone can't overwrite Host header

What is the problem you are having with rclone?

Rclone --header flag doesn't overwrite Host header.

Run the command 'rclone version' and share the full output of the command.

rclone v1.64.2

  • os/version: rocky 8.8 (64 bit)
  • os/kernel: 4.18.0-477.27.1.el8_8.x86_64 (x86_64)
  • os/type: linux
  • os/arch: amd64
  • go/version: go1.21.3
  • go/linking: static
  • go/tags: none

Which cloud storage system are you using? (eg Google Drive)

S3 / MinIO

The command you were trying to run (eg rclone copy /tmp remote:tmp)

rclone --config /usr/rclone/config/rclone.conf --no-check-certificate=true --dump=headers --header 'Host: drive.mydomain.ext' lsd backend:

Please run 'rclone config redacted' and share the full output. If you get command not found, please make sure to update rclone.

[backend]
type = s3
provider = Minio
env_auth = false
access_key_id = XXX
secret_access_key = XXX
endpoint = cluster.mydomain.ext:8080
acl = bucket-owner-full-control

A log from the command that you were trying to run with the -vv flag

2023/10/29 11:45:27 NOTICE: Automatically setting -vv as --dump is enabled
2023/10/29 11:45:27 DEBUG : rclone: Version "v1.64.2" starting with parameters ["rclone" "--config" "/usr/rclone/config/rclone.conf" "--no-check-certificate=true" "--dump=headers" "--header" "Host: drive.mydomain.ext" "lsd" "backend:"]
2023/10/29 11:45:27 DEBUG : Creating backend with remote "backend:"
2023/10/29 11:45:27 DEBUG : Using config file from "/usr/rclone/config/rclone.conf"
2023/10/29 11:45:27 DEBUG : You have specified to dump information. Please be noted that the Accept-Encoding as shown may not be correct in the request and the response may not show Content-Encoding if the go standard libraries auto gzip encoding was in effect. In this case the body of the request will be gunzipped before showing it.
2023/10/29 11:45:27 DEBUG : Resolving service "s3" region "us-east-1"
2023/10/29 11:45:27 DEBUG : You have specified to dump information. Please be noted that the Accept-Encoding as shown may not be correct in the request and the response may not show Content-Encoding if the go standard libraries auto gzip encoding was in effect. In this case the body of the request will be gunzipped before showing it.
2023/10/29 11:45:27 DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2023/10/29 11:45:27 DEBUG : HTTP REQUEST (req 0xc00095c700)
2023/10/29 11:45:27 DEBUG : GET / HTTP/1.1
Host: cluster.mydomain.ext:8080
User-Agent: rclone/v1.64.2
Authorization: XXXX
X-Amz-Content-Sha256: e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855
X-Amz-Date: 20231029T104527Z
Accept-Encoding: gzip

2023/10/29 11:45:27 DEBUG : >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
2023/10/29 11:45:27 DEBUG : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2023/10/29 11:45:27 DEBUG : HTTP RESPONSE (req 0xc00095c700)
2023/10/29 11:45:27 DEBUG : HTTP/1.1 200 OK
Accept-Ranges: bytes
Connection: keep-alive
Content-Type: text/html; charset=utf-8
Date: Sun, 29 Oct 2023 10:45:27 GMT
Etag: "29af-606bc5cf23b72-gzip"
Last-Modified: Mon, 02 Oct 2023 14:12:23 GMT
Server: nginx/1.23.3
Vary: Accept-Encoding

2023/10/29 11:45:27 DEBUG : <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
2023/10/29 11:45:27 DEBUG : 6 go routines active

You would need to change the endpoint instead

The subdomain cluster points directly to a load balancing, but drive.mydomain.ext points to Cloudflare, it isn't the same.

You can't override the host header, alas, you'll have to think of a different way of achieving what you want.

So I have to edit the source code. Can you give me a hint where to look?

What are you trying to do? If the host header worked then it would have done the same as changing endpoint.

Do you want some queries to go to one place and some another?

I'm trying to have my requests sent directly to the destination host (a load balancer), without going through the proxy (Cloudflare). A host header for subdomain drive.mydomain.ext is required.
Here's my solution: Changing endpoint and adding these lines to the /etc/hosts file
<LOAD_BALANCER_IP_ADDRESS_1> drive.mydomain.ext
<LOAD_BALANCER_IP_ADDRESS_2> drive.mydomain.ext

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.