move nginx conf files to /tmp/nginx/conf
This commit is contained in:
parent
dab8e5a17c
commit
7df3279cea
@ -10,7 +10,7 @@ http {
|
|||||||
log_format https_combined '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" HTTPS';
|
log_format https_combined '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" HTTPS';
|
||||||
log_format http_combined '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" HTTP';
|
log_format http_combined '$remote_addr - $remote_user [$time_local] "$request" $status $body_bytes_sent "$http_referer" "$http_user_agent" HTTP';
|
||||||
|
|
||||||
include /tmp/nginx/*;
|
include /tmp/nginx/conf/*;
|
||||||
|
|
||||||
server {
|
server {
|
||||||
listen *:80 default_server;
|
listen *:80 default_server;
|
||||||
|
@ -10,6 +10,7 @@ import os
|
|||||||
import logging
|
import logging
|
||||||
|
|
||||||
target_path = "/tmp/nginx/"
|
target_path = "/tmp/nginx/"
|
||||||
|
config_path = target_path + "conf/"
|
||||||
pid_file = "/var/run/nginx.pid"
|
pid_file = "/var/run/nginx.pid"
|
||||||
non_location_template = """# proxy for container '$containername'
|
non_location_template = """# proxy for container '$containername'
|
||||||
server {
|
server {
|
||||||
@ -127,8 +128,8 @@ def handle_container(id):
|
|||||||
'body_size': get_if_available(proxy_data, 'body_size', '1m'),
|
'body_size': get_if_available(proxy_data, 'body_size', '1m'),
|
||||||
'listen': '*:80'
|
'listen': '*:80'
|
||||||
}
|
}
|
||||||
logging.info('writing to %sproxy_%s', target_path, id)
|
logging.info('writing to %sproxy_%s', config_path, id)
|
||||||
with open(target_path + '/proxy_{id}_{code}'.format(id=id,code=env_key), 'w') as file:
|
with open(config_path + '/proxy_{id}_{code}'.format(id=id,code=env_key), 'w') as file:
|
||||||
if substitutes['location'] == '':
|
if substitutes['location'] == '':
|
||||||
del substitutes['location']
|
del substitutes['location']
|
||||||
logging.info(Template(non_location_template).safe_substitute(substitutes))
|
logging.info(Template(non_location_template).safe_substitute(substitutes))
|
||||||
@ -192,9 +193,11 @@ if __name__ == '__main__':
|
|||||||
# prepare required stuff
|
# prepare required stuff
|
||||||
pid = get_pid()
|
pid = get_pid()
|
||||||
logging.info('nginx pid: %s', str(pid))
|
logging.info('nginx pid: %s', str(pid))
|
||||||
if not os.path.exists(target_path):
|
if not os.path.exists(config_path):
|
||||||
logging.info('creating target path: %s', target_path)
|
logging.info('creating target path: %s', target_path)
|
||||||
os.mkdir(target_path)
|
os.mkdir(target_path)
|
||||||
|
logging.info('creating target path: %s', config_path)
|
||||||
|
os.mkdir(config_path)
|
||||||
|
|
||||||
client = Client(base_url='unix://var/run/docker.sock', version='1.15')
|
client = Client(base_url='unix://var/run/docker.sock', version='1.15')
|
||||||
|
|
||||||
@ -229,10 +232,10 @@ if __name__ == '__main__':
|
|||||||
# since a container can expose multiple ports per PROXY_DATA it
|
# since a container can expose multiple ports per PROXY_DATA it
|
||||||
# will generate multiple files. All names contain the container id.
|
# will generate multiple files. All names contain the container id.
|
||||||
# This will be used to delete all relevant files for a container
|
# This will be used to delete all relevant files for a container
|
||||||
for filename in os.listdir(target_path):
|
for filename in os.listdir(config_path):
|
||||||
if container_id in filename:
|
if container_id in filename:
|
||||||
logging.info('removing file %s%s', target_path, container_id)
|
logging.info('removing file %s%s', config_path, container_id)
|
||||||
os.remove(target_path + filename)
|
os.remove(config_path + filename)
|
||||||
else:
|
else:
|
||||||
handle_container(container_id)
|
handle_container(container_id)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user