What is the right place for sub_filter?

Hi!

My site runs php-cgi (via fastcgi) & nginx 1.4.4.
I need to replace www.domain refs to www1.domain ones.
Where to place sub_filter - in server{}, or “location /”, or “location ~
.php$”,…?

sub_filter www.domain www1.domain;
sub_filter_types *;

I tried all these places w/o success.

Posted at Nginx Forum: