Skip to content

SSRF_PROXY_ALLOW_PRIVATE_IPS / SSRF_PROXY_ALLOW_PRIVATE_DOMAINS set in envs/infrastructure/ssrf-proxy.env have no effect #40415

Closed

Description

@orangeclk

Self Checks

  • I have read the Contributing Guide and Language Policy.
  • This is only for bug report, if you would like to ask a question, please head to Discussions.
  • I have searched for existing issues search for existing issues, including closed ones.
  • I confirm that I am using English to submit this report, otherwise it will be closed.
  • 【中文用户 & Non English User】请使用英语提交,否则会被关闭 :)
  • Please do not modify this template :) and fill in all the required fields.

Dify version

Latest (the bug exists in the current main docker-compose configuration; present in recent releases as well)

Cloud or Self Hosted

  • Self Hosted (Docker)

Steps to reproduce

  1. Copy docker/envs/infrastructure/ssrf-proxy.env.example to docker/envs/infrastructure/ssrf-proxy.env.
  2. Set values in that file, e.g.:
    SSRF_PROXY_ALLOW_PRIVATE_IPS=10.0.0.0/8
    SSRF_PROXY_ALLOW_PRIVATE_DOMAINS=internal.example.com
    
  3. Start the deployment: docker compose up -d.
  4. Inspect what the ssrf_proxy container actually receives:
    docker compose exec ssrf_proxy env | grep SSRF
    docker compose logs ssrf_proxy | grep -i allow
    

✔️ Expected Behavior

The values configured in docker/envs/infrastructure/ssrf-proxy.env should take effect, so the allowlist written into the squid config (dify_allowed_private_networks / dify_allowed_private_domains) reflects them. Per the documented convention in docker/README.md:

Docker Compose reads envs/*.env files when present, then reads .env last so values in .env take precedence.

So setting the variables in the root .env should still be able to override envs/infrastructure/ssrf-proxy.env.

❌ Actual Behavior

The ssrf_proxy service does not load envs/infrastructure/ssrf-proxy.env at all. The two variables are only wired via environment: interpolation (${SSRF_PROXY_ALLOW_PRIVATE_IPS:-}), which reads from the root .env only — edits to envs/infrastructure/ssrf-proxy.env are silently ignored.

Additionally, dify-env-sync strips these two variables from the root .env during upgrades (they live in the envs/ category, not the root .env.example), so configuring them in .env does not survive an upgrade either. envs/infrastructure/ssrf-proxy.env is the natural home for them per the project's env-file design, but that path is currently broken.

Activity

  1. dosubot commented on Aug 10, 2026

    @dosubot

    This bug report is valid — there are actually two issues here:

    1. ssrf_proxy service doesn't load envs/infrastructure/ssrf-proxy.env

    The ssrf_proxy service in docker-compose.yaml has no env_file: directive pointing to ssrf-proxy.env. It only uses environment: with shell interpolation from the root .env [1]:

    SSRF_PROXY_ALLOW_PRIVATE_IPS: ${SSRF_PROXY_ALLOW_PRIVATE_IPS:-}
    SSRF_PROXY_ALLOW_PRIVATE_DOMAINS: ${SSRF_PROXY_ALLOW_PRIVATE_DOMAINS:-}

    So values set in envs/infrastructure/ssrf-proxy.env are silently ignored, even though that file's .example template [2] lists both variables — which is misleading. Other Dify services (api, worker, web) do load ssrf-proxy.env via shared YAML anchors [3], but the ssrf_proxy container itself does not.

    2. SSRF_PROXY_ALLOW_PRIVATE_DOMAINS is missing from root .env.example

    SSRF_PROXY_ALLOW_PRIVATE_IPS is present in docker/.env.example [4], but SSRF_PROXY_ALLOW_PRIVATE_DOMAINS is not. Since dify-env-sync rebuilds .env from .env.example and only preserves variables that exist in the template, running the sync tool will strip SSRF_PROXY_ALLOW_PRIVATE_DOMAINS if a user manually added it to root .env.

    Workaround for now: Add both variables directly to the root docker/.env file (not the envs/infrastructure/ file), and be aware that SSRF_PROXY_ALLOW_PRIVATE_DOMAINS may be removed by dify-env-sync on upgrades and need to be re-added.

    To fix this properly, two changes would be needed:

    1. Add SSRF_PROXY_ALLOW_PRIVATE_DOMAINS to docker/.env.example so it survives sync
    2. Either add an env_file: directive to the ssrf_proxy service for ssrf-proxy.env, or remove these variables from ssrf-proxy.env.example to avoid confusion

    To reply, just mention @dosu.


    Docs are dead. Just use Dosu.

    Leave Feedback Ask Dosu about dify

  2. yang0228 commented on Sep 3, 2026

    @yang0228

    Thanks @dosu for confirming the issue and outlining the current behavior.

    I'd like to work on this issue. I reproduced the behavior against the current main branch and have a patch ready.

    The proposed fix:

    • Load ./envs/infrastructure/ssrf-proxy.env directly for the ssrf_proxy service.
    • Keep these optional allowlist settings scoped to the infrastructure env file.
    • Preserve non-empty legacy root .env and shell overrides through scoped override variables, without loading the entire root .env into the Squid container.
    • Fall back to the infrastructure values when a legacy root override is empty.
    • Add regression coverage for Compose resolution, override precedence, and preventing unrelated root secrets from entering the container.

    I also validated the behavior with a real Squid container, including private-domain allow/deny behavior and IP allowlist fallback.

    Could a maintainer please assign this issue to me? Once assigned, I'll open the PR.

  3. orangeclk commented on Sep 4, 2026

    @orangeclk
    ContributorAuthor

    I've already made a PR and I have reopened it. @yang0228

  4. 41tair commented on Nov 5, 2026

    @41tair
    Member

    Fixed in #45359.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions