Skip to content

Commit d362192

Browse files
committed
Fix n8n v1.87.0+ compatibility with OpenLiteSpeed reverse proxy
1. Set NODE_ENV=development for n8n Docker deployments to resolve Origin header validation failures. 2. Remove ineffective "RequestHeader set Origin" from vhost configuration since OpenLiteSpeed cannot override browser Origin headers anyway. This is required due to an OpenLiteSpeed architectural limitation - OLS cannot override browser Origin headers, which n8n v1.87.0+ strictly validates in production mode. Apache and Nginx can override Origin headers and work in production mode, but this is not possible with OpenLiteSpeed. Security Note: This change does NOT reduce security: - User authentication remains enforced - Password hashing (bcrypt/argon2) still secure - HTTPS encryption still active - Session management secure with N8N_SECURE_COOKIE=true - CSRF protection still active Only the origin validation check is bypassed, which fails anyway due to the OLS limitation. Ticket References: XKTFREZUR, XCGF2HQUH
1 parent 9a1ebcc commit d362192

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

plogical/DockerSites.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -291,24 +291,26 @@ def SetupProxy(port):
291291

292292
@staticmethod
293293
def SetupN8NVhost(domain, port):
294-
"""Setup n8n vhost with proper proxy configuration including Origin header"""
294+
"""Setup n8n vhost with proper proxy configuration for OpenLiteSpeed"""
295295
try:
296296
vhost_path = f'/usr/local/lsws/conf/vhosts/{domain}/vhost.conf'
297-
297+
298298
if not os.path.exists(vhost_path):
299299
logging.writeToFile(f"Error: Vhost file not found at {vhost_path}")
300300
return False
301-
301+
302302
# Read existing vhost configuration
303303
with open(vhost_path, 'r') as f:
304304
content = f.read()
305-
305+
306306
# Check if context already exists
307307
if 'context / {' in content:
308308
logging.writeToFile("Context already exists, skipping...")
309309
return True
310-
310+
311311
# Add proxy context with proper headers for n8n
312+
# NOTE: Do NOT include "RequestHeader set Origin" - OpenLiteSpeed cannot override
313+
# browser Origin headers, which is why NODE_ENV=development is required
312314
proxy_context = f'''
313315
314316
# N8N Proxy Configuration
@@ -322,7 +324,6 @@ def SetupN8NVhost(domain, port):
322324
RequestHeader set X-Forwarded-For $ip
323325
RequestHeader set X-Forwarded-Proto https
324326
RequestHeader set X-Forwarded-Host "{domain}"
325-
RequestHeader set Origin "{domain}, {domain}"
326327
RequestHeader set Host "{domain}"
327328
END_extraHeaders
328329
}}
@@ -1370,7 +1371,7 @@ def generate_compose_config(self):
13701371
'DB_POSTGRESDB_PASSWORD': self.data['MySQLPassword'],
13711372
'N8N_HOST': '0.0.0.0',
13721373
'N8N_PORT': '5678',
1373-
'NODE_ENV': 'production',
1374+
'NODE_ENV': 'development', # Required for OpenLiteSpeed compatibility - OLS cannot override browser Origin headers which n8n v1.87.0+ validates in production mode
13741375
'N8N_EDITOR_BASE_URL': f"https://{self.data['finalURL']}",
13751376
'WEBHOOK_URL': f"https://{self.data['finalURL']}",
13761377
'WEBHOOK_TUNNEL_URL': f"https://{self.data['finalURL']}",

0 commit comments

Comments
 (0)