mirror of
https://github.com/thecyberlearn/quantumtaskai-caprover.git
synced 2026-08-18 12:32:56 +00:00
- Fix ALLOWED_HOSTS configuration in dokploy.json (set to *) - Update production_settings.py to respect SECURE_SSL_REDIRECT environment variable - Change startup script to use netcop_hub.production_settings instead of production_https_settings - Add proper environment variable handling for SSL and CSRF settings - Resolve SSL redirect conflicts between Dokploy proxy and Django settings
79 lines
2.2 KiB
Python
79 lines
2.2 KiB
Python
"""
|
|
Production settings for netcop_hub project.
|
|
"""
|
|
|
|
from .settings import *
|
|
import os
|
|
|
|
# SECURITY WARNING: don't run with debug turned on in production!
|
|
DEBUG = False
|
|
|
|
# Parse ALLOWED_HOSTS from environment
|
|
allowed_hosts_str = os.environ.get('ALLOWED_HOSTS', '')
|
|
if allowed_hosts_str:
|
|
ALLOWED_HOSTS = [host.strip() for host in allowed_hosts_str.split(',') if host.strip()]
|
|
else:
|
|
ALLOWED_HOSTS = []
|
|
|
|
# Database
|
|
DATABASES = {
|
|
'default': {
|
|
'ENGINE': 'django.db.backends.postgresql',
|
|
'NAME': os.environ.get('DB_NAME'),
|
|
'USER': os.environ.get('DB_USER'),
|
|
'PASSWORD': os.environ.get('DB_PASSWORD'),
|
|
'HOST': os.environ.get('DB_HOST', 'localhost'),
|
|
'PORT': os.environ.get('DB_PORT', '5432'),
|
|
}
|
|
}
|
|
|
|
# Static files
|
|
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')
|
|
|
|
# Security settings - respect environment variables for Dokploy compatibility
|
|
SECURE_SSL_REDIRECT = os.environ.get('SECURE_SSL_REDIRECT', 'true').lower() == 'true'
|
|
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
|
|
SECURE_CONTENT_TYPE_NOSNIFF = True
|
|
SECURE_BROWSER_XSS_FILTER = True
|
|
|
|
# Only enable secure cookies and HSTS if SSL redirect is enabled
|
|
if SECURE_SSL_REDIRECT:
|
|
SECURE_HSTS_SECONDS = 31536000
|
|
SECURE_HSTS_INCLUDE_SUBDOMAINS = True
|
|
SECURE_HSTS_PRELOAD = True
|
|
SESSION_COOKIE_SECURE = True
|
|
CSRF_COOKIE_SECURE = True
|
|
else:
|
|
SESSION_COOKIE_SECURE = False
|
|
CSRF_COOKIE_SECURE = False
|
|
|
|
# Trust proxy headers for Dokploy/Traefik
|
|
USE_X_FORWARDED_HOST = True
|
|
USE_X_FORWARDED_PORT = True
|
|
|
|
# CSRF trusted origins from environment
|
|
csrf_origins_str = os.environ.get('CSRF_TRUSTED_ORIGINS', '')
|
|
if csrf_origins_str:
|
|
CSRF_TRUSTED_ORIGINS = [origin.strip() for origin in csrf_origins_str.split(',') if origin.strip()]
|
|
else:
|
|
CSRF_TRUSTED_ORIGINS = []
|
|
|
|
# Logging
|
|
LOGGING = {
|
|
'version': 1,
|
|
'disable_existing_loggers': False,
|
|
'handlers': {
|
|
'file': {
|
|
'level': 'INFO',
|
|
'class': 'logging.FileHandler',
|
|
'filename': '/var/log/django/netcop_hub.log',
|
|
},
|
|
},
|
|
'loggers': {
|
|
'django': {
|
|
'handlers': ['file'],
|
|
'level': 'INFO',
|
|
'propagate': True,
|
|
},
|
|
},
|
|
} |