Introduction
Years ago, there were several mirror sites of Google available in China. I was always curious about how they worked. Recently, that memory resurfaced, and I decided to give it a go. In theory, you can mirror almost any website.
Nginx Configuration
Let’s use Baidu as an example. The key configuration directives are proxy_pass
and proxy_set_header
. Essentially, this is just a reverse proxy setup.
To mirror a site like Baidu, you can use the following minimal configuration. It forwards all incoming requests to the real website while setting the appropriate host header.
|
|
You can also use a more advanced approach. For instance, if a website requires login, you can insert a logged-in cookie directly into the configuration, restrict access by IP address, and then share this proxy with others. Here’s a practical example: I’m overseas and want to let my friends in China use ChatGPT. I can mirror chat.openai.com
on a server with external access, and inject my own logged-in cookie. This way, when my friends visit the mirrored site, they can use ChatGPT directly.
|
|