Guide

Put DroppedNeedle behind a reverse proxy

What any reverse proxy must send DroppedNeedle, how to serve it under a sub-path, and how to fix saves refused with Origin not allowed.

Admins only Checked against v3.1.0 Updated Edit this page Report a problem

Liner notes

At a glance

Who
Admins only
You need
  • A reverse proxy you already run, forwarding to DroppedNeedle's port (8688 by default)
  • Access to the compose file, to set environment variables

DroppedNeedle doesn’t terminate TLS itself, so HTTPS comes from your proxy. What it needs from the proxy is the same whichever one you run, and the app ships no proxy-specific configuration. Where its docs name an nginx directive, it is given below. For another proxy, use its matching setting.

Before you start#

  • Make sure DroppedNeedle already works at its own address, such as http://your-server:8688. You need that address if a save through the proxy is refused.
  • Know which address the proxy connects to DroppedNeedle from. Behind Docker it is often the bridge gateway (the compose example shows 172.17.0.1), or the proxy container’s or host’s IP. Step 1 shows how to find it if you are not sure.

Steps#

  1. Find the address your proxy connects from#

    Open DroppedNeedle through the proxy and sign in, then read the log with docker compose logs droppedneedle. If the proxy is on a private address and not yet trusted, the log says so once and names it: Ignoring the forwarded headers sent by <address>, which is not a trusted proxy.

  2. List the proxy in TRUSTED_PROXY_IPS#

    Add it to the environment of the DroppedNeedle service. It takes IPs or CIDRs, comma-separated:

    docker-compose.yml
    environment:
      - TRUSTED_PROXY_IPS=172.17.0.1

    The list replaces the default, 127.0.0.1,::1. List every address family the proxy arrives on. * trusts every peer: use it only behind a proxy that strips forwarded headers a client made up. Only a trusted proxy has its X-Forwarded-* headers believed, and that decides HTTPS detection, the Secure sign-in cookie, per-client rate limits and the addresses music apps are given.

  3. Pass Host and X-Forwarded-Proto through#

    Have the proxy send the Host header exactly as the browser sent it, port included (or the same value as X-Forwarded-Host), and set X-Forwarded-Proto to the scheme the browser used. In nginx, proxy_set_header Host $http_host; keeps the port, where $host drops it.

  4. Stop the proxy buffering live updates#

    Each open tab keeps one long-lived connection to /api/v3/events/stream. In nginx, set proxy_buffering off; and proxy_read_timeout 1h; for that path. DroppedNeedle already sends X-Accel-Buffering: no. Don’t let the proxy compress text/event-stream either.

  5. Raise the upload limit#

    Drop imports send up to 8 GB in one request. nginx accepts 1 MB by default: set client_max_body_size 8g; (or 0 for no limit). Cloudflare’s proxy takes at most 100 MB per request on the Free and Pro plans. Behind a reverse proxy has the timeouts to raise.

  6. Recreate the container#

    bash
    docker compose up -d
  7. Test a save through the proxy#

    Open DroppedNeedle at the proxy’s address, change a setting and press Save.

    Result: the save goes through, and the log has no new Ignoring the forwarded headers line.

Serve DroppedNeedle under a sub-path

Set BASE_PATH to the prefix, such as - BASE_PATH=/music, and recreate the container. Everything moves under the base path: the web UI, /api/v3, the Subsonic and Jellyfin APIs, and /health, which the container’s health check follows. Point the proxy at the prefix without stripping it: a request outside the prefix gets a 404.

The value must start with /, have no trailing /, use only letters, digits and . _ ~ -, be at most 256 characters, and not start with /api.

State the public address

If you can’t make the proxy pass the right headers, tell DroppedNeedle where people open it. Open DroppedNeedle at its own address and port, go to Settings › Security and find the Public address card (“Where people open DroppedNeedle, for when saving is refused there.”).

Under Addresses, enter the address people open DroppedNeedle at, as the browser’s address bar shows it, up to the host and port, such as https://music.example.com. Leave out any path, the base path too. You can list up to eight. Use this page’s address adds the address of the page you are on. Press Save.

Only list addresses where this DroppedNeedle opens: “A page at a listed address can make changes as whoever is signed in.” This is the public address setting. If you can only reach DroppedNeedle through the proxy, set it on the host instead:

bash
docker compose stop droppedneedle
docker compose run --rm droppedneedle droppedneedle-tool public-address https://music.example.com
docker compose up -d droppedneedle

--show prints the saved list and --clear empties it.

Turn on HSTS

Under Settings › Security › HTTP Strict Transport Security (HSTS), Max-Age (seconds) is 0 by default, which is off. HSTS is only sent for requests that a trusted proxy marked X-Forwarded-Proto: https. If your proxy already adds Strict-Transport-Security, leave it at 0. Read HSTS before you turn it on: browsers remember it.

Let a dashboard show DroppedNeedle in a frame

Under Settings › Security › Content-security policy, add the dashboard’s address (such as https://home.example.com) to Allowed to frame DroppedNeedle, up to eight. Nobody may frame DroppedNeedle by default.

Check it worked#

  • A save made through the proxy goes through instead of answering 403 Origin not allowed.
  • Scan progress, now playing and download pop-ups change without a reload.
  • /health at the proxy’s address (under the base path, if you set one) answers {"status":"ok","message":"DroppedNeedle backend running"}.

If something went wrong#

Each heading below is the message DroppedNeedle shows.

403 Origin not allowed

Sign-in works, but every save is refused. The proxy is giving DroppedNeedle the wrong idea of its own address, and the log says once which part: Refused a change from a page at …: this server sees itself at …, followed by “the reverse proxy is dropping the port or hiding HTTPS” or “is replacing the Host header”. Fix steps 2 and 3, or state the public address (above). It is the reverse proxy, not the account.

The server does not accept this page's address yet, so it refused the save.

The Public address card can’t be saved from the address that is being refused. Open DroppedNeedle directly at its own address and port and save there, or use droppedneedle-tool public-address on the host.

Ignoring the forwarded headers sent by …, which is not a trusted proxy.

The log names the proxy’s address. Add it to TRUSTED_PROXY_IPS and recreate the container. Until then, every client shares the proxy’s rate limits and HTTPS goes undetected.

Now playing, scan progress and download pop-ups only change when you reload

Something between the browser and DroppedNeedle is holding back /api/v3/events/stream. Turn off buffering and compression for it (step 4).

A blank page, and the browser console names the content-security policy

A proxy is rewriting the page or injecting a script, such as Cloudflare’s Rocket Loader. Turn that off for DroppedNeedle’s address. Until then, switch the content-security policy to report-only on the host:

bash
docker compose stop droppedneedle
docker compose run --rm droppedneedle droppedneedle-tool content-security-policy report-only
docker compose up -d droppedneedle
invalid BASE_PATH value

The server refuses to start, and the message ends with the reason, such as must not end with '/' or must not start with /api: that prefix belongs to the API. Fix the value and recreate the container. The same goes for invalid TRUSTED_PROXY_IPS, which names the entry that is not an IP, a CIDR or *.

Docs