Update Dify configuration in .env.example and Caddyfile

- Removed deprecated DIFY_DB and DIFY_CELERY_BROKER_URL variables from .env.example.
- Updated Caddyfile to change the reverse proxy port for Dify from 80 to 8080.
- Enhanced start_services.py to dynamically set NGINX_PORT to prevent port conflicts.
This commit is contained in:
Yury Kossakovsky
2025-08-06 18:57:40 -06:00
parent 43d7dd6b4e
commit 75e154ecea
3 changed files with 23 additions and 13 deletions

View File

@@ -295,16 +295,6 @@ LANGCHAIN_API_KEY=
# Based on: https://docs.dify.ai/en/getting-started/install-self-hosted/environments
############
DIFY_SECRET_KEY=
# Dify uses shared Redis and PostgreSQL from n8n-installer
DIFY_CELERY_BROKER_URL=redis://redis:6379/1
DIFY_DB_HOST=postgres
DIFY_DB_PORT=5432
DIFY_DB_USERNAME=postgres
DIFY_DB_PASSWORD=${POSTGRES_PASSWORD}
DIFY_DB_DATABASE=dify
DIFY_REDIS_HOST=redis
DIFY_REDIS_PORT=6379
DIFY_REDIS_DB=0
###########################################################################################
COMPOSE_PROFILES="n8n,flowise,monitoring"

View File

@@ -22,7 +22,7 @@
# Dify
{$DIFY_HOSTNAME} {
reverse_proxy dify-nginx:80
reverse_proxy dify-nginx:8080
}
# Langfuse

View File

@@ -171,6 +171,7 @@ def prepare_dify_env():
# Get the secret key from main .env
secret_key = env_values.get("DIFY_SECRET_KEY", "")
dify_nginx_port = env_values.get("DIFY_NGINX_PORT", "8080")
if secret_key:
# Replace SECRET_KEY if it exists, otherwise append it
@@ -186,26 +187,45 @@ def prepare_dify_env():
# Append SECRET_KEY at the end
dify_env_content += f"\n# Added by n8n-installer\nSECRET_KEY={secret_key}\n"
# Change NGINX_PORT to prevent port 80 conflict
if "NGINX_PORT=" in dify_env_content:
# Find the NGINX_PORT line and replace it
lines = dify_env_content.split('\n')
for i, line in enumerate(lines):
if line.strip().startswith("NGINX_PORT="):
lines[i] = f"NGINX_PORT={dify_nginx_port}"
print(f"Changed Dify NGINX_PORT from 80 to {dify_nginx_port} to prevent port conflict")
break
dify_env_content = '\n'.join(lines)
else:
# Append NGINX_PORT configuration
dify_env_content += f"\n# Port configuration to prevent conflicts (added by n8n-installer)\nNGINX_PORT={dify_nginx_port}\n"
print(f"Added Dify NGINX_PORT={dify_nginx_port} to prevent port 80 conflict")
# Write the updated content back
with open(dify_env_path, "w") as f:
f.write(dify_env_content)
print("Successfully copied Dify .env.example and added SECRET_KEY")
print("Successfully copied Dify .env.example and added SECRET_KEY and port configuration")
else:
print("Warning: DIFY_SECRET_KEY not found in main .env file")
else:
# Fallback: create basic .env if .env.example doesn't exist
print("Warning: Dify .env.example not found, creating basic .env configuration...")
secret_key = env_values.get("DIFY_SECRET_KEY", "")
dify_nginx_port = env_values.get("DIFY_NGINX_PORT", "8080")
dify_env_content = f"""# Dify Environment Configuration
# Generated from n8n-installer main .env
# Core Dify Configuration
SECRET_KEY={secret_key}
# Port configuration to prevent conflicts (added by n8n-installer)
NGINX_PORT={dify_nginx_port}
"""
with open(dify_env_path, "w") as f:
f.write(dify_env_content)
print("Created basic Dify .env configuration")
print(f"Created basic Dify .env configuration with NGINX_PORT={dify_nginx_port}")
except Exception as e:
print(f"Error preparing Dify .env configuration: {e}")