There are a lot of problems with this approach (lack of access to real IP, etc.) , and given the improved availability of Google Analytics services in China, it is no longer recommended. If reliability is sought, it is recommended to use domestic services or self-built statistical services.
You can find nginx.conf for reversing proxy Google Analytics on Google, but most of them are for the old version. And so do reCaptcha's. After solving some issues, here's my code.
Attention: 1. ngx_http_substitutions_filter_module module needed。 2. DO NOT ADD X-Frame-Options DENY WHILE CONFIGURING SSL (SOMEORIGIN would be fine for self using, not tested) 3. After reverse proxy reCaptcha, challenge will be difficult. (Using proxies will reduce credibility, and some code uses complex obfuscations that result in client-side identification code can't be modified)