You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Open Web App link drops external port when APP_WEB_URL is empty (reproduced on 1.17.1) #43877
Related: #37780, which was closed as not planned. This report provides a reproduction on 1.17.1 and a verified proxy-level workaround.
Environment: macOS, Docker Desktop, bundled Nginx reverse proxy, Chrome. Dify is exposed on host port 8081; APP_WEB_URL is empty. App identifiers below are placeholders.
Deploy Dify with the bundled Nginx proxy and expose its HTTP listener on a non-standard host port, e.g. EXPOSE_NGINX_PORT=8081.
Leave APP_WEB_URL unset/empty.
Access the console at http://localhost:8081.
Create and publish a chat application.
Open the Publish menu and click Open Web App.
Observe that the generated link omits :8081.
✔️ Expected Behavior
The generated link preserves the browser-facing host and port:
http://localhost:8081/chat/<app-code>
Opening it should load the published application.
❌ Actual Behavior
The generated link is:
http://localhost/chat/<app-code>
It targets port 80 rather than Dify's exposed port 8081. In this environment another local HTTP listener answers with 404. On a host without a port-80 listener, the symptom may instead be a connection failure.
Verified before the workaround:
Generated console link omitted :8081.
The port-80 URL returned HTTP 404.
The same application path at localhost:8081 returned HTTP 200.
This appears in api/models/model.py (Site.app_base_url) and api/controllers/console/app/app.py. With APP_WEB_URL empty, the forwarded request host therefore loses the external port.
Verified local workaround
Changed the Host forwarding directive in both the active Nginx configuration and its persistent template:
Then ran nginx -t successfully, reloaded Nginx, and refreshed the console.
After the change:
The Open Web App link included localhost:8081.
Clicking the actual link opened the published chat application.
The application title, welcome message, existing conversation, and chat input loaded successfully. Verification went beyond the HTTP 200 response; no new model inference was run for this check.
Explicitly setting APP_WEB_URL=http://localhost:8081 is another configuration workaround, but was not applied in this reproduction.
Please consider preserving the external authority (including non-standard port) in the bundled proxy/fallback URL generation, or documenting the required explicit URL setting alongside custom port configuration. The $http_host change above is a locally verified workaround, not a claim that it is sufficient for every reverse-proxy topology.
Hi @siqiniao! I'm Dosu and I'm helping the Dify team.
Your root cause analysis holds. The bundled template still sets Host $host and X-Forwarded-Port $server_port. When APP_WEB_URL is unset, the Site.app_base_url fallback uses the incoming request root [1], and $host drops the port.
PR #37893, "fix: preserve web app URL port through nginx", makes your $http_host change. It forwards Host as $http_host and adds a template regression test. I couldn't confirm whether it has merged, and the template in the checkout I read still has $host.
Until the template changes, two other options can restore the port:
Set APP_WEB_URL explicitly, e.g. APP_WEB_URL=http://localhost:8081. This is the most reliable option.
Set RESPECT_XFORWARD_HEADERS_ENABLED=true. This wraps the app in Werkzeug's ProxyFix, which rebuilds the host from X-Forwarded-Port[2]. The template already sends that header, but $server_port is the nginx listener port, so with a Docker mapping like 8081:80 it would carry the internal port. I haven't verified whether this gives you :8081 in your setup.
#37780 reported the same behaviour for generated MCP server URLs [2], so a fix in the nginx template would cover both.
Reproduced on 1.17.1 with APP_WEB_URL empty: the Open Web App link drops the external port. Changing nginx Host forwarding from $host to $http_host preserves it.
Activity
dosubot commentedon Oct 11, 2026
Hi @siqiniao! I'm Dosu and I'm helping the Dify team.
Your root cause analysis holds. The bundled template still sets
Host $hostandX-Forwarded-Port $server_port. WhenAPP_WEB_URLis unset, theSite.app_base_urlfallback uses the incoming request root [1], and$hostdrops the port.PR #37893, "fix: preserve web app URL port through nginx", makes your
$http_hostchange. It forwardsHostas$http_hostand adds a template regression test. I couldn't confirm whether it has merged, and the template in the checkout I read still has$host.Until the template changes, two other options can restore the port:
APP_WEB_URLexplicitly, e.g.APP_WEB_URL=http://localhost:8081. This is the most reliable option.RESPECT_XFORWARD_HEADERS_ENABLED=true. This wraps the app in Werkzeug'sProxyFix, which rebuilds the host fromX-Forwarded-Port[2]. The template already sends that header, but$server_portis the nginx listener port, so with a Docker mapping like8081:80it would carry the internal port. I haven't verified whether this gives you:8081in your setup.#37780 reported the same behaviour for generated MCP server URLs [2], so a fix in the nginx template would cover both.
To reply, just mention @dosu.
Docs are dead. Just use Dosu.
Stream29 commentedon Oct 12, 2026
Reproduced on 1.17.1 with
APP_WEB_URLempty: the Open Web App link drops the external port. Changing nginx Host forwarding from$hostto$http_hostpreserves it.Before:

After:
