# Proxy settings IS_BEHIND_PROXY = get_from_env("IS_BEHIND_PROXY", False, type_cast=str_to_bool) TRUSTED_PROXIES = os.getenv("TRUSTED_PROXIES", None) TRUST_ALL_PROXIES = os.getenv("TRUST_ALL_PROXIES", False) if IS_BEHIND_PROXY: USE_X_FORWARDED_HOST = True USE_X_FORWARDED_PORT = True SECURE_PROXY_SSL_HEADER = ("HTTP_X_FORWARDED_PROTO", "https") if not TRUST_ALL_PROXIES and not TRUSTED_PROXIES: print_warning( ( "️You indicated your instance is behind a proxy (IS_BEHIND_PROXY env var),", " but you haven't configured any trusted proxies. See", " https://posthog.com/docs/configuring-posthog/running-behind-proxy for details.", ) ) # IP Block settings ALLOWED_IP_BLOCKS = get_list(os.getenv("ALLOWED_IP_BLOCKS", "")) ALLOWED_HOSTS = get_list(os.getenv("ALLOWED_HOSTS", "*")) # Quick-start development settings - unsuitable for production # See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/ DEFAULT_SECRET_KEY = "<randomly generated secret key>" # SECURITY WARNING: keep the secret key used in production secret! SECRET_KEY = os.getenv("SECRET_KEY", DEFAULT_SECRET_KEY)
from posthog.settings.base_variables import DEBUG, IS_COLLECT_STATIC, TEST from posthog.settings.utils import get_from_env, print_warning, str_to_bool from posthog.version_requirement import ServiceVersionRequirement SKIP_SERVICE_VERSION_REQUIREMENTS = get_from_env( "SKIP_SERVICE_VERSION_REQUIREMENTS", TEST or IS_COLLECT_STATIC or DEBUG, type_cast=str_to_bool ) if SKIP_SERVICE_VERSION_REQUIREMENTS and not (TEST or DEBUG): print_warning(["Skipping service version requirements. This is dangerous and PostHog might not work as expected!"]) SERVICE_VERSION_REQUIREMENTS = [ ServiceVersionRequirement(service="postgresql", supported_version=">=11.0.0,<=14.1.0",), ServiceVersionRequirement(service="redis", supported_version=">=5.0.0,<=6.3.0",), ServiceVersionRequirement(service="clickhouse", supported_version=">=21.6.0,<21.12.0"), ]
# Overridden in posthog-cloud import sys from posthog.settings.utils import get_from_env, print_warning, str_to_bool # Early exit to avoid issues with cloud not being properly included if get_from_env("MULTI_TENANCY", False, type_cast=str_to_bool): print_warning(( "️Environment variable MULTI_TENANCY is set, but cloud settings have not been included", )) sys.exit("[ERROR] Stopping Django server…\n")
import os import sys from posthog.settings.utils import get_from_env, print_warning, str_to_bool # Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname( os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) DEBUG = get_from_env("DEBUG", False, type_cast=str_to_bool) TEST = ("test" in sys.argv or sys.argv[0].endswith("pytest") or get_from_env("TEST", False, type_cast=str_to_bool)) # type: bool E2E_TESTING = get_from_env( "E2E_TESTING", False, type_cast=str_to_bool, ) # whether the app is currently running for E2E tests BENCHMARK = get_from_env("BENCHMARK", False, type_cast=str_to_bool) if E2E_TESTING: print_warning([ "️WARNING! E2E_TESTING is set to `True`. This is a security vulnerability unless you are running tests." ]) IS_COLLECT_STATIC = len(sys.argv) > 1 and sys.argv[1] == "collectstatic" if DEBUG and not TEST: print_warning(( "️Environment variable DEBUG is set - PostHog is running in DEVELOPMENT MODE!", "Be sure to unset DEBUG if this is supposed to be a PRODUCTION ENVIRONMENT!", ))