From f2f1ed05be2098fd058208b34992339595d32e4a Mon Sep 17 00:00:00 2001 From: Jan Philip Wahle Date: Sun, 21 Aug 2022 19:58:50 +0200 Subject: [PATCH] Use nginx in docker again and keys of host system. This way host does not need nginx and file copy. --- Dockerfile | 9 +++++++-- nginx.conf | 20 +++++++++++++------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index fa0fc1e..1613c52 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -FROM node:18 +FROM node:18 as builder RUN mkdir /cs-insights-frontend WORKDIR /cs-insights-frontend @@ -6,4 +6,9 @@ COPY ./ /cs-insights-frontend WORKDIR /cs-insights-frontend RUN npm install -RUN npm run build --omit=dev \ No newline at end of file +RUN npm run build --omit=dev + +FROM nginx:latest + +COPY --from=builder /cs-insights-frontend/build /usr/share/nginx/html/ +COPY --from=builder /cs-insights-frontend/nginx.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/nginx.conf b/nginx.conf index 7108675..6ef86f0 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,10 +1,16 @@ server { - listen 80; - listen 443 ssl; - server_name: www.cs-insights.uni-goettingen.de; + listen 80 default_server; + listen [::]:80 default_server; + server_name _; + return 301 https://$host$request_uri; +} + +server { + listen 443 default ssl; + server_name cs-insights.uni-goettingen.de; ssl_certificate /etc/letsencrypt/live/cs-insights/fullchain.pem; ssl_certificate_key /etc/letsencrypt/live/cs-insights/privkey.pem; - + error_log /var/log/nginx/debug.log debug; gzip on; gzip_proxied any; gzip_types @@ -22,7 +28,7 @@ server { try_files $uri $uri/ /index.html; index index.html index.htm; } - + location /api/ { proxy_pass http://backend:3000/api/; proxy_http_version 1.1; @@ -31,5 +37,5 @@ server { proxy_set_header Host $host; proxy_cache_bypass $http_upgrade; client_max_body_size 16400M; - } -} + } +} \ No newline at end of file