nginxwebserverproxypassssi

nginx proxy_pass do not pass uri


My goal is, that the call of domain.com/do/that/ will include the page otherdomain.com/for/that/and replaces a part of that content with ssi & subs filter. Also, it is important if someone calls domain.com/do/that/for-me, the included page will just request otherdomain.com/for/that and not otherdomain.com/for/that/for-me.

I currently have set up this:

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;
}

What would be the way to achieve that "ignore" of uri?


Solution

  • Already found out the solution:

    I just use a var with the static URL and set it to the 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;
    }