1
0
mirror of https://github.com/Mailu/Mailu.git synced 2025-06-17 00:07:45 +02:00

Add letsencrypt support in the nginx container

This commit is contained in:
kaiyou
2017-09-24 17:50:10 +02:00
parent a57096e613
commit 808809b37a
5 changed files with 87 additions and 13 deletions

View File

@ -1,13 +1,15 @@
#!/usr/bin/python
import jinja2
import os
import socket
convert = lambda src, dst: open(dst, "w").write(jinja2.Template(open(src).read()).render(**os.environ))
import subprocess
# Actual startup script
if "ADMIN_ADDRESS" not in os.environ:
os.environ["ADMIN_ADDRESS"] = socket.gethostbyname("admin")
convert("/conf/nginx.conf", "/etc/nginx/nginx.conf")
if not os.path.exists("/certs/dhparam.pem") and os.environ["TLS_FLAVOR"] != "notls":
os.system("openssl dhparam -out /certs/dhparam.pem 4096")
if os.environ["TLS_FLAVOR"] == "letsencrypt":
subprocess.Popen(["/letsencrypt.py"])
subprocess.call(["/config.py"])
os.execv("/usr/sbin/nginx", ["nginx", "-g", "daemon off;"])