dsh-public-origin: Resolving the DSH Plugin Loopback Address Issue in Reverse Proxy Environments

Introduction

DeepSeek Harness (DSH) adopts a plugin-based architecture. When DSH Web is deployed on a VPS and accessed via a public domain name (e.g., https://your.domain) combined with a reverse proxy, some third-party plugins fail. Symptoms include: iframes in the settings page pointing to 127.0.0.1 being rejected by the browser, administrative operations throwing errors, and diagnostic interfaces returning 403. The root cause is that plugins assume the browser is accessing from a loopback address and check whether the Host/Origin is a loopback address. This plugin uniformly handles such loopback address issues without modifying any third-party plugin files.

What is this

dsh-public-origin is a DSH plugin maintained by user JJDonald and licensed under the MIT license. Its core value is to enable third-party plugins to work correctly under a “public domain name + reverse proxy” deployment, while ensuring security through DSH’s own authentication mechanisms.

Core Features

  1. Uniformly handle loopback address issues behind reverse proxies: Fixes iframe rejection issues during browser access.
  2. Modify billion-context (bili) routing: Returns the origin of the current page at /bili/origin and performs same-origin reverse proxying under /__bili/*; modifies the bili management API to remove Origin, Referer, and other headers to access as a loopback identity.
  3. Modify specific plugin Hosts: Rewrites the request Host for reasoning-effort and skill-explorer to a loopback address.
  4. Distinguish request sources: Distinguishes between local direct connections and reverse-proxied requests based on socket addresses (127/8 or ::1) and X-Forwarded-* headers.
  5. Integrate DSH Authentication: Authenticates reverse-proxied requests through DSH’s own connection.requestRejection (relying on --trusted-host, cross-site request marking, and Origin same-origin validation).
  6. Idle Timeout: Bili proxy requests will be aborted if idle for 5 minutes without activity.
  7. Security Fix: Fixes the v0.1.0 authentication bypass vulnerability by no longer relying on the Host header for judgment, preventing login bypass via spoofed Host headers.

Installation

Use the official installation command:

dsh plugin --profile web add github:JJDonald/dsh-public-origin

Restart the DSH Web instance after installation.

Configuration

In the profile’s cordis.patch.yml, you can override configurations to specify route prefixes that need to be handled:

- id: public-origin
  config:
    localize:
      - /dsh-better-reasoning-effort
      - /api/dsh-skill-explorer

The handling of bili is enabled by default and is not affected by this list.

Prerequisites and Deployment Notes

  1. Environment Dependencies: Depends on DSH 0.2.0-rc.2+ and Node.js >= 22.
  2. DSH Startup Parameters: DSH needs to be started with --trusted-host <domain> and should only listen on loopback addresses (e.g., --host 127.0.0.1).
  3. Reverse Proxy Configuration:
    • Must set X-Forwarded-For or X-Real-IP and X-Forwarded-Proto. The plugin relies on these headers to identify requests passing through the reverse proxy.
    • It is recommended to fix the Host to the public domain name ($server_name) and do not forward the client’s Host as-is. Example configuration:
location / {
    proxy_pass http://127.0.0.1:3080;
    proxy_http_version 1.1;
    proxy_set_header Host $server_name;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
    proxy_set_header X-Forwarded-Proto https;
    proxy_set_header Upgrade $http_upgrade;
    proxy_set_header Connection $connection_upgrade;
    proxy_buffering off;
}
  1. Security Boundaries:
    • Local Direct Connection: Requests where the socket peer address belongs to 127/8 or ::1 and do not carry any X-Forwarded-* headers are passed to the original plugins as-is.
    • Reverse Proxied Requests: First pass through DSH authentication; return 401 if not logged in, 403 if untrusted, and are rewritten to a loopback identity only after passing.

Compatibility

  • Current Version: 0.2.1.
  • Dependencies: DSH 0.2.0-rc.2+, Node.js >= 22.
  • Unofficial Plugin: Please check the source code and license before installing and using.

Summary

dsh-public-origin solves the compatibility issues of third-party plugins in the DSH ecosystem under public network reverse proxy deployments. By intercepting, rewriting Host and Origin, and integrating DSH gates, it achieves secure and stable loopback address compatibility without modifying upstream plugin code.

羽毛球分组比赛记分
小程序二维码

欢迎使用《羽毛球分组比赛记分》微信小程序

Xiaoye