没有传递路径的 NginX 反向代理

NginX reverse proxy without pass path

我想在 Nginx 中使用反向代理的“proxy_pass”,具有以下行为:

总而言之,我想代理所有路径到我的代理网站的根目录。

我有这个,但没用:

location / {
    proxy_pass https://myproxyweb.com/;
    }

它不起作用,因为当我尝试转到“https://myweb.com/foo”时,Nginx 尝试显示“https://myproxyweb.com/foo”

尝试:

server
{
  listen 443 ssl http2:
  server_name myweb.com;

  # TO DO: Configure SSL certificate

  location /
  {
    return 301 https://myproxyweb.com$is_args$args;
  }

  location /foo
  {
    return 301 https://myproxyweb.com;
  }
}

server
{
  listen 443 ssl http2;
  server_name myproxyweb.com;

  # TO DO: Configure SSL certificate

  ...

}