-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathconfig.py.TEMPLATE
124 lines (104 loc) · 4.04 KB
/
config.py.TEMPLATE
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
########################################################################
# Configuration template for hxl-proxy
#
# Copy this to config.py (or similar), then change the values to suit.
# Before launching the application, set the environment variable
# HXL_PROXY_CONFIG to the full path to your config file, so that
# the hxl-proxy app can find it.
########################################################################
import os
import redis
from urllib.parse import urlparse
import distutils.util as util
# use app.debug to detect debug mode
#
# Set the Python logging level for the app
# See https://docs.python.org/3/library/logging.html#logging-levels
#
LOGGING_LEVEL = os.getenv('LOGGING_LEVEL', 'ERROR')
#
# Set the request timeout (not currently synced with server)
#
TIMEOUT = os.getenv('TIMEOUT', 30)
#
# Special logging level for access to remote URLs
# (These are logged under "hxl.REMOTE_ACCESS" rather than a module name)
#
REMOTE_ACCESS_LOGGING_LEVEL = os.getenv('REMOTE_ACCESS_LOGGING_LEVEL', 'INFO')
REMOTE_ACCESS_LOG_FILE = os.getenv('REMOTE_ACCESS_LOG_FILE', "/var/log/proxy/hxl.log")
#
# Root logging level
# This is the minimum logging level that will be allowed
#
ROOT_LOGGING_LEVEL = os.getenv('ROOT_LOGGING_LEVEL', 'INFO')
#
# Environment type
# If we are developing, we'd rather not see json logs.
#
ENV_TYPE = os.getenv('ENV_TYPE', 'PROD')
#
# Change this to a key known only to your server
# (Used to secure cookies)
#
SECRET_KEY = os.getenv('SECRET_KEY', '<secret key>')
#
# Allow list of domain to contact
# This should be a comma-separated list of domains and subdomains
# Do NOT use hostnames
#
ALLOWED_DOMAINS_LIST = list(filter(None, [l.strip().strip('.') for l in os.getenv('ALLOWED_DOMAINS_LIST', '').split(',')]))
#
# Admin password MD5 hash
# To generate, use this command (replacing "PASSWORD" with your password):
# $ python -c 'import hashlib; print(hashlib.md5("PASSWORD".encode("utf-8")).hexdigest())'
#
ADMIN_PASSWORD_MD5 = os.getenv('ADMIN_PASSWORD_MD5', '<md5 hash>')
#
# Input configuration (reading remote datasets)
#
MAX_REQUEST_TIMEOUT = int(os.getenv('REQUEST_TIMEOUT', 30)) # maximum allowable request timeout
#
# Output cache configuration
# see https://flask-caching.readthedocs.io/en/latest/#built-in-cache-backends
#
CACHE_CONFIG = {
# possible types: filesystem, redis
'CACHE_TYPE': os.getenv('CACHE_TYPE', 'filesystem'),
# redis output cache
'CACHE_KEY_PREFIX': os.getenv('CACHE_KEY_PREFIX', 'hxl-proxy-out:'),
'CACHE_DEFAULT_TIMEOUT': os.getenv('CACHE_DEFAULT_TIMEOUT', 3600),
'CACHE_REDIS_PASSWORD': os.getenv('CACHE_REDIS_PASSWORD', ''),
'CACHE_REDIS_URL': os.getenv('CACHE_REDIS_URL', "redis://localhost:6379/1"),
# filesystem output cache options
'CACHE_DIR': os.getenv('CACHE_DIR', '/tmp/'),
'CACHE_THRESHOLD': int(os.getenv('CACHE_THRESHOLD', 1000))
}
if CACHE_CONFIG['CACHE_TYPE'] == 'redis':
cache_redis_url = urlparse(CACHE_CONFIG['CACHE_REDIS_URL'])
if len(cache_redis_url.path) > 1:
cache_redis_db = cache_redis_url.path[1:]
CACHE_CONFIG.update({
'CACHE_REDIS_HOST': cache_redis_url.hostname,
'CACHE_REDIS_PORT': cache_redis_url.port,
'CACHE_REDIS_DB': cache_redis_db
})
# input cache: memory or redis
REQUEST_CACHE_BACKEND = os.getenv('REQUEST_CACHE_BACKEND', 'memory')
REQUEST_CACHE_TIMEOUT_SECONDS = os.getenv('REQUEST_CACHE_TIMEOUT_SECONDS', 3600)
if REQUEST_CACHE_BACKEND == 'redis':
REQUEST_CACHE_EXTRAS = {
"connection": redis.from_url(CACHE_CONFIG['CACHE_REDIS_URL'])
}
REQUEST_CACHE_NAME = os.getenv('REQUEST_CACHE_NAME','hxl-proxy-in') # no trailing colon needed
# Cache name and timeout for requests to iTOS
# (otherwise uses REQUEST_CACHE_*): memory or redis
ITOS_CACHE_NAME = 'itos-in' # no trailing colon needed
ITOS_CACHE_BACKEND = 'memory'
ITOS_CACHE_TIMEOUT = 604800
#
# Values for Google Drive access
#
GOOGLE_CLIENT_ID = os.getenv('GOOGLE_CLIENT_ID', '<client id>')
GOOGLE_OAUTH_ID = os.getenv('GOOGLE_OAUTH_ID', '<oauth id>')
GOOGLE_TAG_MANAGER_ID = os.getenv('GOOGLE_TAG_MANAGER_ID', '<google tag manager id>')
# end