From 543318dd8a5232ed3c1adb58c43e79733a80c67b Mon Sep 17 00:00:00 2001 From: Fred Boniface Date: Tue, 11 Jul 2023 23:49:14 +0100 Subject: [PATCH] Fix nginx config for proxy to API server --- dockerfile | 1 + nginx.conf | 34 +++++++++++++++++++++++++--------- src/lib/stores/version.js | 2 +- 3 files changed, 27 insertions(+), 10 deletions(-) diff --git a/dockerfile b/dockerfile index e090527..63003cd 100644 --- a/dockerfile +++ b/dockerfile @@ -8,6 +8,7 @@ COPY . ./ RUN npm run build FROM nginx:alpine-slim +RUN rm -f /etc/nginx/nginx.conf COPY ./nginx.conf /etc/nginx/nginx.conf COPY --from=build /app/build /usr/share/nginx/html RUN chown -R nginx:nginx /usr/share/nginx/html \ No newline at end of file diff --git a/nginx.conf b/nginx.conf index 6a9c503..e0f7712 100644 --- a/nginx.conf +++ b/nginx.conf @@ -26,24 +26,40 @@ http { #gzip-static on; + proxy_cache_path /var/cache/nginx keys_zone=owl_cache:20m inactive=24h; + + upstream backend { + server owlboard-backend:8460; + } + server { listen 80; listen [::]:80; server_name localhost; + proxy_cache owl_cache; - root /usr/share/nginx/html; - index index.html; + add_header Content-Security-Policy "default-src 'self'"; location / { + root /usr/share/nginx/html; + index index.html; + gzip_static on; + error_page 500 502 503 504 /50x.html; try_files $uri $uri.html $uri/ =404; + add_header Cache-Control "public, no-transform, max-age=1209600"; + } + + location /misc/ { + proxy_pass http://backend; + } + + location /api/ { + proxy_pass http://backend; + proxy_cache_key $scheme://$host$uri$is_args$query_string; + proxy_ignore_headers Cache-Control; + proxy_cache_valid 200 2m; # Evaluate whether 2m or 1m is more appropriate + add_header Cache-Control "private, no-transform, max-age=120"; } - - #error_page 404 /404.html; - # redirect server error pages to the static page /50x.html - error_page 500 502 503 504 /50x.html; - location = /50x.html { - root /usr/share/nginx/html; - } } } \ No newline at end of file diff --git a/src/lib/stores/version.js b/src/lib/stores/version.js index 24a1478..25df065 100644 --- a/src/lib/stores/version.js +++ b/src/lib/stores/version.js @@ -1,3 +1,3 @@ export const version = '2023.7.1'; -export const versionTag = 'dev'; +export const versionTag = 'beta'; export const showWelcome = true;