nginx proxy_pass 不传递 uri

nginx proxy_pass do not pass uri

我的目标是 domain.com/do/that/ 的调用将包含页面 otherdomain.com/for/that/ 并用 ssi 和 subs 过滤器替换该内容的一部分。 此外,重要的是,如果有人调用 domain.com/do/that/for-me,包含的页面只会请求 otherdomain.com/for/that 而不是 otherdomain.com/for/that/for-me.

我目前已经设置了这个:

location ^~/do/that/ {
  proxy_pass http://otherdomain.com/do/that/;

  ssi on;
  subs_filter_types text/html;

  set $includeUri "";
  if ( $uri != "/do/that/" ){
    set $includeUri "$uri-parts";
  }

 subs_filter '<div class="rpl-container">' '<div class="rpl-container"><!--# include virtual="/my-ssi-include/$includeUri" -->' ir;
}

实现 "ignore" uri 的方法是什么?

已经找到解决方法:

我只是使用带有静态 URL 的 var 并将其设置为 proxy_pass

location ^~/do/that/ {
  set $staticUrl 'http://otherdomain.com/do/that/';
  proxy_pass $staticUrl;

  ssi on;
  subs_filter_types text/html;

  if ($uri ~* "/do/that/(.*\.html)"){
    set $includeUri "";
  }

 subs_filter '<div class="rpl-container">' '<div class="rpl-container"><!--# include virtual="/my-ssi-include/$includeUri" -->' ir;
}