Set (sub)domain name via environment
diff --git a/nginx/Dockerfile b/nginx/Dockerfile
index 18cbc8e..9809c58 100644
--- a/nginx/Dockerfile
+++ b/nginx/Dockerfile
@@ -23,3 +23,9 @@
 
 
 FROM nginx_${SSL_VARIANT}
+
+COPY nginx/Dockerfile.entrypoint /nginx-entrypoint
+RUN chmod 544 /nginx-entrypoint
+
+ENTRYPOINT ["/bin/sh", "/nginx-entrypoint"]
+CMD ["nginx", "-g", "daemon off;"]
diff --git a/nginx/Dockerfile.entrypoint b/nginx/Dockerfile.entrypoint
new file mode 100644
index 0000000..0c2ff96
--- /dev/null
+++ b/nginx/Dockerfile.entrypoint
@@ -0,0 +1,27 @@
+#!/bin/sh
+
+set -e
+
+{
+    domain=${SA_PUBLIC_DOMAIN_NAME:-miau.local}
+    html=/var/www/html
+
+    rm -rf ${html}
+    cp -a /var/www/simpleid ${html}
+
+    for tmpl in /var/db/simpleid-templates/*.identity; do
+        ref=$(dirname ${tmpl})/$(basename ${tmpl} .identity)
+        name=$(basename ${ref})
+        sed "s/miau.local/${domain}/" ${ref} >${html}/${name}
+    done
+
+    for f in /etc/nginx/conf.d/sa.conf; do
+        sed "s/miau.local/${domain}/" ${f}.template >${f}
+    done
+}
+
+chown -R nginx:nginx /var/www/html/
+
+chmod -R a-w /etc/nginx/conf.d/sa.conf /var/www/html/
+
+exec /docker-entrypoint.sh "$@"