How to set up a reverse proxy for Google using Caddy?

1. The problem I’m having:

I can open the homepage, but the search feature doesn’t work.

2. Error messages and/or full log output:

3. Caddy version:

v2.7.6

4. How I installed and ran Caddy:

apt install Caddy

5. Caddy config:

{
        admin
}

(dnspod_token) {
        dns dnspod xxxxxx,bbbbbbbbbbbbbbbbbbbbbbbbbbbbb
}

s.xxxx.top {
	tls {
			import dnspod_token
	}
    reverse_proxy https://www.google.com {
        header_up Host {upstream_hostport}
        
    }
    
}

Technically, it does work.

As you type your search in a browser pointed to Caddy, the browser sends your keystrokes via XMLHttpRequest to Caddy. Caddy then forwards them to Google, and you’ll see the browser receiving responses and suggesting possible search phrases.

The issue happens when you hit enter to actually submit the search. At that point, Google flags the request with an HTTP 429 and a 302 redirect to https://www.google.com/sorry/index, which includes a CAPTCHA. Their anti-bot protection is pretty strict and tends to block these kinds of setups.

Unfortunately, I don’t think there’s a straightforward Caddy directive that can get around this.

1 Like