36 lines
1.1 KiB
Python
36 lines
1.1 KiB
Python
from requests import get
|
|
from subprocess import call
|
|
|
|
|
|
hosts = get('http://configurator/api/v1/fetch?project=certupdater&stage=development').json()['configs']['hosts']
|
|
hosts = list(set(hosts + ['platform.develop.sprinthub.ru']))
|
|
|
|
config = ''
|
|
for host in hosts:
|
|
config += '''
|
|
server \{
|
|
listen 443 ssl http2;
|
|
listen [::]:443 ssl http2;
|
|
server_name {0};
|
|
|
|
ssl_certificate /etc/nginx/{0}/fullchain.pem;
|
|
ssl_certificate_key /etc/nginx/{0}/privkey.pem;
|
|
|
|
add_header X-Frame-Options "SAMEORIGIN" always;
|
|
add_header X-XSS-Protection "1; mode=block" always;
|
|
add_header X-Content-Type-Options "nosniff" always;
|
|
add_header Referrer-Policy "no-refferer-when-downgrade" always;
|
|
add_header Content-Security-Policy "default-src * data: 'unsafe-eval' 'unsafe-inline'" always;
|
|
|
|
location / \{
|
|
proxy_pass http://{1}-nginx:1238$request_uri;
|
|
\}
|
|
\}\n\n
|
|
'''.format(host, host.split('.')[0])
|
|
|
|
with open('/etc/nginx/hosts.conf', 'w') as fp:
|
|
fp.write(config)
|
|
|
|
|
|
call('nginx -g daemon off;', shell=True)
|