Skip to content

安全环境变量(Security environment variables)#

File-based configuration

You can add _FILE to individual variables to provide their configuration in a separate file. Refer to Keeping sensitive data in separate files for more details.

| 变量 | 类型 | 默认值 | 描述 |

| :------- | :---- | :------- | :---------- |

| N8N_BLOCK_ENV_ACCESS_IN_NODE | 布尔值 | false | 是否允许用户在表达式和代码节点中访问环境变量(false 表示不允许,true 表示允许)。 |

| N8N_BLOCK_FILE_ACCESS_TO_N8N_FILES | 布尔值 | true | 设置为 true 以阻止访问 .n8n 目录中的所有文件和用户定义的配置文件。 |

| N8N_ENFORCE_SETTINGS_FILE_PERMISSIONS | 布尔值 | false | 将其设置为 true 以尝试为设置文件设置 0600 权限,仅允许所有者读取和写入。 |

| N8N_RESTRICT_FILE_ACCESS_TO | 字符串 | | 限制对这些目录中文件的访问。将多个文件作为以分号分隔的列表提供(";")。 |

| N8N_SECURITY_AUDIT_DAYS_ABANDONED_WORKFLOW | 数字 | 90 | 如果工作流未执行,则考虑其已被放弃的天数。 |

|N8N_CONTENT_SECURITY_POLICY| 字符串 | {} | 将 Content-Security-Policy 头设置为 helmet.js 嵌套指令对象。例如,{ "frame-ancestors": ["http://localhost:3000"] } |

| N8N_SECURE_COOKIE | 布尔值 | true | 确保 Cookie 仅通过 HTTPS 发送,增强安全性。|

| N8N_SAMESITE_COOKIE | 枚举字符串:strictlaxnone | lax | 控制跨站点 Cookie 行为(了解更多):

  • strict:仅发送给第一方请求。
  • lax(默认):随顶层导航请求发送。
  • none:在所有上下文中发送(需要 HTTPS)。
|

| N8N_GIT_NODE_DISABLE_BARE_REPOS | 布尔值 | false | 设置为 true 以防止 Git 节点 与裸仓库一起使用,从而增强安全性。 |

| N8N_GIT_NODE_ENABLE_HOOKS | 布尔值 | false | 设置为 true 以允许 Git 节点 执行 Git 钩子。 |

使用环境变量的安全策略(Security policy using environment variables)#

N8N_SECURITY_POLICY_MANAGED_BY_ENV 设置为 true 以通过环境变量管理安全策略。有关激活模式的工作原理,请参阅 使用环境变量管理实例设置

🌐 Set N8N_SECURITY_POLICY_MANAGED_BY_ENV to true to manage the security policy from environment variables. See Manage instance settings using environment variables for how the activation pattern works.

Variable Type Default Description
N8N_SECURITY_POLICY_MANAGED_BY_ENV Boolean false Set to true to manage the security policy from environment variables. When true, n8n applies the security policy variables on every startup and locks the matching UI controls.
N8N_MFA_ENFORCED_ENABLED Boolean false Whether to enforce two-factor authentication for all users (true) or not (false).
N8N_PERSONAL_SPACE_PUBLISHING_ENABLED Boolean true Whether users can publish from their personal space (true) or not (false).
N8N_PERSONAL_SPACE_SHARING_ENABLED Boolean true Whether users can share resources from their personal space (true) or not (false).