I seem to be unable to get sub_filter to work with PHP-FPM on nginx
location ~ \.php$ {
try_files $uri =404;
fastcgi_pass unix:/var/run/php-fpm/php-fpm.sock;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
include fastcgi_params;
proxy_set_header Accept-Encoding ""; # no compression allowed or next won't work
sub_filter '<a href="http://' '<a href="//';
sub_filter '<img src="http://' '<img src="//';
sub_filter_once off;
sub_filter_types *;
}
For reference, the filter works perfectly fine with plain HTML files
location / {
try_files $uri $uri/ =404;
proxy_set_header Accept-Encoding ""; # no compression allowed or next won't work
sub_filter '<a href="http://' '<a href="//';
sub_filter '<img src="http://' '<img src="//';
sub_filter_once off;
}
Any help would be appreciated