1
0
mirror of https://github.com/Mailu/Mailu.git synced 2025-11-29 22:37:58 +02:00

Force nginx to run dns queries at runtime

This commit is contained in:
kaiyou
2017-11-13 21:38:04 +01:00
parent dc79e6e539
commit eb32871904
2 changed files with 24 additions and 7 deletions

View File

@@ -7,6 +7,13 @@ convert = lambda src, dst, args: open(dst, "w").write(jinja2.Template(open(src).
args = os.environ.copy()
# Get the first DNS server
with open("/etc/resolv.conf") as handle:
content = handle.read().split()
args["RESOLVER"] = content[content.index("nameserver") + 1]
# TLS configuration
args["TLS"] = {
"cert": ("/certs/cert.pem", "/certs/key.pem"),
"mail": ("/certs/cert.pem", "/certs/key.pem"),
@@ -20,6 +27,7 @@ if args["TLS"] and not all(os.path.exists(file_path) for file_path in args["TLS"
args["TLS_ERROR"] = "yes"
# Build final configuration paths
convert("/conf/tls.conf", "/etc/nginx/tls.conf", args)
convert("/conf/nginx.conf", "/etc/nginx/nginx.conf", args)
os.system("nginx -s reload")