"sub_filter_once off" not working as advertised?

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

"sub_filter_once off" not working as advertised?

Jason Whittington

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 J.

 

 

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@01CD7B01.8E79C0A0

WORKFORCE
SOLUTIONS

(o) 314.214.7163 | (m) 636.284.4082

[hidden email]

 

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 [hidden email]. Equifax® is a registered trademark of Equifax Inc. All rights reserved.
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

Re: "sub_filter_once off" not working as advertised?

Maxim Dounin
Hello!

On Tue, Dec 12, 2017 at 04:34:36PM +0000, Jason Whittington wrote:

> 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

Given the space between "sub_filter" and "once", it is expected to
replace "once" with "off" somewhere in the response.  You probably
mean to write

              sub_filter_once off;

instead.

[...]

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
Reply | Threaded
Open this post in threaded view
|

RE: [IE] Re: "sub_filter_once off" not working as advertised?

Jason Whittington
Oh geez - I knew it was going to be something stupid!  Thanks!  :)

-----Original Message-----
From: nginx [mailto:[hidden email]] On Behalf Of Maxim Dounin
Sent: Tuesday, December 12, 2017 11:07 AM
To: [hidden email]
Subject: [IE] Re: "sub_filter_once off" not working as advertised?

Hello!

On Tue, Dec 12, 2017 at 04:34:36PM +0000, Jason Whittington wrote:

> 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

Given the space between "sub_filter" and "once", it is expected to replace "once" with "off" somewhere in the response.  You probably mean to write

              sub_filter_once off;

instead.

[...]

--
Maxim Dounin
http://mdounin.ru/
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx
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 [hidden email]. Equifax® is a registered trademark of Equifax Inc. All rights reserved.
_______________________________________________
nginx mailing list
[hidden email]
http://mailman.nginx.org/mailman/listinfo/nginx