0

For some reason sub_filter doesn't works with fastcgi_pass which is pointing to CGI script in perl in my case.

If I try to apply sub_filter to static HTML all works fine and it swaps hrefs as expected.

Here's the config:

location /proxy/
    sub_filter '<a href="http://'  '<a href="//';
    sub_filter_once off;

    fastcgi_pass             proxy:8002;
    fastcgi_split_path_info  ^(/proxy)(/?.*)$;
    fastcgi_param            SCRIPT_NAME $fastcgi_script_name;
    fastcgi_param            PATH_INFO $fastcgi_path_info;

    include fastcgi_params;
    fastcgi_buffers 256 4k;
    fastcgi_intercept_errors on;
    fastcgi_read_timeout 14400;
  }
Artem S.
  • 543
  • 5
  • 16

1 Answers1

0

I found in this answer that problem might be with compression that my backend script does. In case of proxy_pass they use proxy_set_header Accept-Encoding ""; to turn off compression.

In my case with fastcgi_pass this directive helped me (found related answer here):

fastcgi_param HTTP_ACCEPT_ENCODING "";
Artem S.
  • 543
  • 5
  • 16