How to Inject a Umami script via NPM
Here is the exact, step-by-step Nginx Proxy Manager (NPM) configuration to successfully inject a custom script into any host.
Do not use the standard "Advanced" tab, as NPM's default routing will override your rules. You must use a Custom Location.
- Edit your Seerr proxy host and ensure the Advanced tab is completely empty.
- Go to the Custom locations tab and click Add location.
- Fill in the standard routing details:
- Location:
/ - Forward Hostname / IP: [Your Seerr IP or Container Name]
- Forward Port:
5055
- Location:
- Click the gear icon (⚙️) in that same row to open the Custom Nginx Configuration box.
- Paste the following snippet (replace the
<script>tag with your tracking code):
# Disable upstream compression so Nginx can read and modify the HTML
proxy_set_header Accept-Encoding "";
# Target only HTML files to save resources
sub_filter_types text/html;
# Inject the tracking script right before the closing head tag
sub_filter '</head>' '<script defer src="https://umami.domain.com/script.js" data-website-id="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"></script></head>';
# Run only once per page load
sub_filter_once on;
- Click Save.
Remember to force-refresh your browser (Ctrl + F5 or Cmd + Shift + R) to clear the cache and see the injected script in the source code.