diff --git a/Dockerfile b/Dockerfile index 993eb36..3090715 100644 --- a/Dockerfile +++ b/Dockerfile @@ -9,9 +9,11 @@ RUN npm run build # Production-Phase FROM nginx:1.25 +# Eigene Nginx-Konfiguration kopieren +COPY default.conf /etc/nginx/conf.d/default.conf + # Nginx konfigurieren für non-root Port 8080 -RUN sed -i 's/listen\( \)*80;/listen 8080;/g' /etc/nginx/conf.d/default.conf && \ - touch /var/run/nginx.pid && \ +RUN touch /var/run/nginx.pid && \ chown -R nginx:nginx /var/run/nginx.pid /var/cache/nginx /var/log/nginx /etc/nginx/conf.d USER nginx diff --git a/default.conf b/default.conf new file mode 100644 index 0000000..6ceb3f6 --- /dev/null +++ b/default.conf @@ -0,0 +1,19 @@ +server { + listen 8080; + server_name localhost; + + # Verhindert, dass Nginx bei 301-Redirects (z.B. ohne Slash) den internen Port 8080 anhängt + port_in_redirect off; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri/ =404; + } + + error_page 404 /404.html; + location = /404.html { + root /usr/share/nginx/html; + internal; + } +}