【问题标题】:nginx proxy_pass do not pass uringinx proxy_pass 不传递uri
【发布时间】:2019-01-15 01:24:32
【问题描述】:

我的目标是,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;
}

实现“忽略”uri 的方法是什么?

【问题讨论】:

    标签: nginx webserver proxypass ssi


    【解决方案1】:

    已经找到解决办法了:

    我只是使用带有静态 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 "$1";
      }
    
     subs_filter '<div class="rpl-container">' '<div class="rpl-container"><!--# include virtual="/my-ssi-include/$includeUri" -->' ir;
    }
    

    【讨论】:

      猜你喜欢
      • 2012-11-27
      • 2019-05-26
      • 1970-01-01
      • 2020-10-20
      • 1970-01-01
      • 2014-03-06
      • 2020-09-04
      • 2020-11-15
      • 2016-03-19
      相关资源
      最近更新 更多