"sub_filter_once off" not working as advertised?

Jason Whittington Jason.Whittington at equifax.com
Tue Dec 12 16:34:36 UTC 2017


I have a rule like the following where I am trying to replace instances of /spf/ with /ec/apps/symmetry/spf/.   I’ve used sub_filter to do this sort of thing before and had luck with it.

        location /ec/apps/symmetry/ {

            proxy_pass http://stl-biz-d2-hrxsymmetry.devapp.c9.equifax.com:55943/;
            proxy_redirect / https://$host/ec/apps/symmetry/;

            #sub filter doesn't work if the upstream server returns compressed or zipped content.
            proxy_set_header Accept-Encoding identity;

            sub_filter once off;  # doesn’t seem to have an effect

            sub_filter '/spf/' '/ec/apps/symmetry/spf/';

            add_header X-nginx-rule /ec/apps/symmetry;
        }

The thing I am seeing here is that even though I specified sub_filter_once off I still only see the first link modified in the html that comes back.   When this html is returned


<html>
<head>
     <title> Welcome </title>


     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <meta name="robots" content="noindex,nofollow"/>
     <script type="text/javascript" src="/spf/resources/js/jquery.js?v=spf_2017-R5"></script>
     <script type="text/javascript" src="/spf/resources/js/bootstrap.js?v=spf_2017-R5"></script>
     <script type="text/javascript" src="/spf/resources/js/underscore.js?v=spf_2017-R5"></script>
     <script type="text/javascript" src="/spf/resources/js/beautify-html.js?v=spf_2017-R5"></script>
     <script type="text/javascript" src="/spf/resources/js/jquery-zoom.js?v=spf_2017-R5"></script>
     <script type="text/javascript" src="/spf/resources/js/spf-new-all.js?v=spf_2017-R5"></script>
     <link href="/spf/resources/css/bootstrap.css?v=spf_2017-R5" type="text/css" media="all" rel="stylesheet">
     <link href="/spf/resources/css/main.css?v=spf_2017-R5" type="text/css" media="all" rel="stylesheet">



This is what I see coming out of nginx:

<html>
<head>
     <title> Welcome </title>


     <meta name="viewport" content="width=device-width, initial-scale=1.0">
     <meta name="robots" content="noindex,nofollow"/>
     <script type="text/javascript" src="/ec/apps/symmetry/spf/resources/js/jquery.js?v=spf_2017-R5"></script>
     <script type="text/javascript" src="/spf/resources/js/bootstrap.js?v=spf_2017-R5"></script>
     <script type="text/javascript" src="/spf/resources/js/underscore.js?v=spf_2017-R5"></script>
     <script type="text/javascript" src="/spf/resources/js/beautify-html.js?v=spf_2017-R5"></script>
     <script type="text/javascript" src="/spf/resources/js/jquery-zoom.js?v=spf_2017-R5"></script>
     <script type="text/javascript" src="/spf/resources/js/spf-new-all.js?v=spf_2017-R5"></script>
     <link href="/spf/resources/css/bootstrap.css?v=spf_2017-R5" type="text/css" media="all" rel="stylesheet">
     <link href="/spf/resources/css/main.css?v=spf_2017-R5" type="text/css" media="all" rel="stylesheet">



 I can see that “X-nginx-rule” header show up in the browser confirming that the request traversing this location block. The fact that anything is modified tells me that gzip and content-type are not getting in the way. sub_filter is filtering, it’s just only doing it one time ☺.


I was able to work around this by just accepting /spf/ in another location block but for future reference – has anyone seen sub_filter only make one substitution even when sub_filter once off is specified?


Jason Whittington | Architect, PD Shared Services
[cid:image001.jpg at 01CD7B01.8E79C0A0]

WORKFORCE
SOLUTIONS

(o) 314.214.7163 | (m) 636.284.4082
jason.whittington at equifax.com<mailto:jason.whittington at equifax.com>

This message contains proprietary information from Equifax which may be confidential. If you are not an intended recipient, please refrain from any disclosure, copying, distribution or use of this information and note that such actions are prohibited. If you have received this transmission in error, please notify by e-mail postmaster at equifax.com. Equifax® is a registered trademark of Equifax Inc. All rights reserved.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20171212/5a74bd5b/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image001.png
Type: image/png
Size: 5085 bytes
Desc: image001.png
URL: <http://mailman.nginx.org/pipermail/nginx/attachments/20171212/5a74bd5b/attachment-0001.png>


More information about the nginx mailing list