I want to send custom headers to the host while using proxies. Take a look at the examples below. Explaining the situation with examples was easier.

This works fine as expected:

curl https://www.cloudflare.com/

When I choose to avoid using DNS by giving host's IP address to curl:


Website gives me this error page -->

"Direct IP access not allowed. You've requested an IP address that is part of the CloudFlare network. A valid Host header must be supplied to reach the desired website."

If we supply correct host header name, it will work normal again without using DNS:

curl --header "Host: cloudflare.com"

But when I do the same while using a proxy tunnel, curl doesn't send the headers to host, so i get "Direct IP access not allowed" error from to the host:

curl --proxy "http://PROXY_IP:PORT" --header "Host: cloudflare.com"

How can i overcome this problem?


This problem should be gone with cURL 7.37.0, which introduced the --proxy-header parameter to specify headers that are meant for the proxy server. Headers given with -H/--header will be seen as "end-server only" now.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.