http {
charset utf-8;
upstream first_back{
server 127.0.0.1:6000;
}
upstream sec_back{
server 127.0.0.1:6001;
}
proxy_next_upstream error;
include /etc/nginx/sites-enabled/some_config;
}
server {
listen 80;
location / {
proxy_pass_header server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://first_back;
}
location /api {
proxy_pass_header server;
proxy_set_header Host $http_host;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Scheme $scheme;
proxy_pass http://sec_back;
}
location /static/ {
root /path/to/static;
}
}
LEVEL = logging.INFO
DATE_FORMAT = "%H:%M:%S %d.%m.%Y"
LOG_FORMAT = "%(lineno)d :: %(name)s :: %(levelname)s :: %(module)s :: %(asctime)s :: %(message)s"
FORMATTER = logging.Formatter(
LOG_FORMAT,
DATE_FORMAT
)
def get_console_handler():
console_handler = logging.StreamHandler(sys.stdout)
console_handler.setFormatter(FORMATTER)
return console_handler
def get_file_handler():
log_file = os.environ.get('LOG_FILE')
if os.path.exists(log_file) is False:
raise FileExistsError('Not found log file')
file_handler = TimedRotatingFileHandler(
log_file,
when='midnight',
encoding=os.environ.get('FILE_CHARSET', 'utf-8'),
backupCount=30
)
file_handler.setFormatter(FORMATTER)
return file_handler