**Edit:** Reproducible example: <https://github.com/searchingforlife/nginx-substitution>

I am trying to add/inject arbitrary number of scripts to an HTML file/output. They all filter on the same value `</body>` to inject themselves.

```
nginx version: nginx/1.16.1

```

Imagine we have two conf files like so (simplified):

```
# script_one.conf

sub_filter "</body>" "<script src='/one.js'></script></body>";

```

```
# script_two.conf

sub_filter "</body>" "<script src='/two.js'></script></body>";

```

And our main nginx conf file:

```
location /one {
  sub_filter_once off;
  include /script_one.conf;
  include /script_two.conf;
}

```

This however does not seem to work and nginx only adds the first script. If the filter value is different (say one filters on `</head>` and the other on `</body>`), then nginx injects both scripts.

Is there a way to get around this limitation and have nginx inject both scripts? I know I can create a new conf file that combines both scripts into one and include that but that just doesn't scale when you have 10+ scripts to inject that can be combined in various ways depending on the location.