diff --git a/docker/test/nginx/Dockerfile b/docker/test/nginx/Dockerfile index c40627d..36ee5b4 100644 --- a/docker/test/nginx/Dockerfile +++ b/docker/test/nginx/Dockerfile @@ -1,4 +1,16 @@ FROM nginx:mainline-alpine COPY nginx.conf /etc/nginx/nginx.conf -COPY paths-enabled /etc/nginx/paths-enabled.d \ No newline at end of file +COPY paths-enabled /etc/nginx/paths-enabled.d + +RUN mkdir -p /etc/nginx/ssl && \ + openssl req -x509 -nodes -days 365 \ + -newkey rsa:2048 \ + -subj "/CN=localhost" \ + -keyout /etc/nginx/ssl/selfsigned.key \ + -out /etc/nginx/ssl/selfsigned.crt \ +COPY entrypoint.sh /entrypoint.sh + +RUN chmod +x /entrypoint.sh + +ENTRYPOINT ["/entrypoint.sh"] \ No newline at end of file diff --git a/docker/test/nginx/entrypoint.sh b/docker/test/nginx/entrypoint.sh new file mode 100644 index 0000000..75d3722 --- /dev/null +++ b/docker/test/nginx/entrypoint.sh @@ -0,0 +1,15 @@ +#!/bin/bash + +CERT_PATH="/etc/letsencrypt/live/api.2martens.de/fullchain.pem" +KEY_PATH="/etc/letsencrypt/live/api.2martens.de/privkey.pem" +NGINX_CONF="/etc/nginx/nginx.conf" + +if [ -f "$CERT_PATH" ] && [ -f "$KEY_PATH" ]; then + echo "✅ Real certificate found — starting full HTTPS Nginx" +else + echo "⚠️ No certificate found — starting Nginx with self-signed TLS fallback" + ln -sf /etc/nginx/ssl/selfsigned.crt /etc/letsencrypt/live/api.2martens.de/fullchain.pem + ln -sf /etc/nginx/ssl/selfsigned.key /etc/letsencrypt/live/api.2martens.de/privkey.pem +fi + +exec nginx -g 'daemon off;'