Nginx 重定向到不同的域保持 request_uri

Nginx redirect to different domain keep request_uri

我希望从我的域重定向用户 www.domain.com/abc/,
参加关于 google docs 在浏览器中保留我的域 url 的调查
到目前为止,这是我尝试过的方法:

location ~ /abc/ {
        1 return 301  https://docs.google.com/forms/abcdefg?usp=sf_link;
        2 set $cleanuri $uri;
        3 return 301 docs.google.com/forms/abcdefg?usp=sf_link;
        4 proxy_set_header X-Rewrite-URL $request_uri;
        5 proxy_set_header X-Rewrite-FullURI $request_uri;
        6 proxy_set_header X-Rewrite-CleanURI $cleanuri;
}

第 1 行:尝试 return url 第 4 行 proxy_set_headerrequest_uri
第 2 行:保存 uri 以与第 3、5、6 行一起使用以在浏览器中保留原始 url。
(希望这是有道理的)。
没有组合 worx.

您不能使用 http://nginx.org/r/return here, neither 301 nor any other code, and http://nginx.org/r/proxy_set_header 单独使用没有任何作用。

您必须使用 http://nginx.org/r/proxy_pass 或 HTML5 iframe:

  • docs.google.com 执行 proxy_pass 可能会导致来自单个 IP 地址的过多请求进入 Google 文档的问题,这可能会促使他们将他们列入黑名单您的 IP 地址,and/or 开始为您的用户提供验证码图像以解决问题;它还可能在 Google 端触发各种跨站点脚本、钓鱼和热链接保护,并由于请求中缺少 google.com cookie 而干扰用户身份验证;简而言之,这可能不受 Google.

  • 支持
  • 同样,由于所谓的点击劫持,HTML iframe 方法现在几乎已经过时了,X-Frame-Options 可能会阻止您这样做嵌入。

简而言之,Google 文档不太可能支持您想做的事情。即使您设法使它工作,它也可能很快就会坏掉。