Skip to content

配置#

¥Configuration

你可以使用环境变量更改 n8n 的设置。有关可用配置的完整列表,请参阅 环境变量

¥You can change n8n's settings using environment variables. For a full list of available configurations see Environment Variables.

通过命令行设置环境变量#

¥Set environment variables by command line

npm#

对于 npm,请在终端中设置所需的环境变量。命令取决于你的命令行。

¥For npm, set your desired environment variables in terminal. The command depends on your command line.

Bash CLI:

1
export <variable>=<value>

在 cmd.exe 中:

¥In cmd.exe:

1
set <variable>=<value>

在 PowerShell 中:

¥In PowerShell:

1
$env:<variable>=<value>

Docker#

在 Docker 中,你可以使用命令行中的 -e 标志:

¥In Docker you can use the -e flag from the command line:

1
2
3
4
5
docker run -it --rm \
 --name n8n \
 -p 5678:5678 \
 -e N8N_TEMPLATES_ENABLED="false" \
 docker.n8n.io/n8nio/n8n

Docker Compose 文件#

¥Docker Compose file

在 Docker 中,你可以在 docker-compose.yaml 文件的 n8n: environment: 元素中设置环境变量。

¥In Docker, you can set your environment variables in the n8n: environment: element of your docker-compose.yaml file.

例如:

¥For example:

1
2
3
n8n:
    environment:
      - N8N_TEMPLATES_ENABLED=false

将敏感数据保存在单独的文件中#

¥Keeping sensitive data in separate files

你可以将 _FILE 附加到各个环境变量,以便在单独的文件中提供它们的配置,从而避免使用环境变量传递敏感信息。n8n 从具有给定名称的文件中加载数据,从而可以从 Docker 密钥Kubernetes Secrets 加载数据。

¥You can append _FILE to individual environment variables to provide their configuration in a separate file, enabling you to avoid passing sensitive details using environment variables. n8n loads the data from the file with the given name, making it possible to load data from Docker-Secrets and Kubernetes-Secrets.

有关每个变量的详细信息,请联系 环境变量

¥Refer to Environment variables for details on each variable.

虽然大多数环境变量都可以使用 _FILE 后缀,但它对敏感数据(例如 credentials 和数据库配置)更有利。以下是一些示例:

¥While most environment variables can use the _FILE suffix, it's more beneficial for sensitive data such as credentials and database configuration. Here are some examples:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
CREDENTIALS_OVERWRITE_DATA_FILE=/path/to/credentials_data
DB_TYPE_FILE=/path/to/db_type
DB_POSTGRESDB_DATABASE_FILE=/path/to/database_name
DB_POSTGRESDB_HOST_FILE=/path/to/database_host
DB_POSTGRESDB_PORT_FILE=/path/to/database_port
DB_POSTGRESDB_USER_FILE=/path/to/database_user
DB_POSTGRESDB_PASSWORD_FILE=/path/to/database_password
DB_POSTGRESDB_SCHEMA_FILE=/path/to/database_schema
DB_POSTGRESDB_SSL_CA_FILE=/path/to/ssl_ca
DB_POSTGRESDB_SSL_CERT_FILE=/path/to/ssl_cert
DB_POSTGRESDB_SSL_KEY_FILE=/path/to/ssl_key
DB_POSTGRESDB_SSL_REJECT_UNAUTHORIZED_FILE=/path/to/ssl_reject_unauth