1

I am trying nginx subfilter module as shown below. I am routing the traffic to reactjs.org and making dynamic text replacements using nginx sub_filter module. The below nginx configuration is not working on any react based websites where I change the text 'React' to 'Test'. How do I overcome this?

location / {
    proxy_pass https://reactjs.org;
    sub_filter '<h1 class="css-159p4b7">React</h1>' '<h1 class="css-159p4b7">Test</h1>';
    sub_filter_once off;
}
jeril
  • 1,109
  • 2
  • 17
  • 35
  • 1
    The reason for that is the response (which you can inspect in the DevTools of a browser such as Chrome) sends back text/html content, which loads a script which modifies the DOM and shows what you see as a React page. – Moe Dec 29 '21 at 23:09

1 Answers1

0

When I had the same issue, Google brought me right to this page, so I think it's important to share an answer.

tl;dr I added the following configuration to the location in my nginx config file:

proxy_set_header Accept-Encoding "";

The explanation why it works is here: https://stackoverflow.com/a/36274259

I hope this helps!