From 21c69671be3f1e25eb87d676a7de9cf2a0e511f0 Mon Sep 17 00:00:00 2001 From: Tracey Jaquith Date: Tue, 9 Apr 2024 22:55:19 +0000 Subject: [PATCH] updated nginx to be easier to hotswap check config changes and be like emularity-engine --- Dockerfile | 5 ++--- default.conf | 16 ++++++++++------ 2 files changed, 12 insertions(+), 9 deletions(-) diff --git a/Dockerfile b/Dockerfile index 48280a7..e29ba1b 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,8 +2,7 @@ FROM nginx:alpine WORKDIR /usr/share/nginx/html -RUN rm -f index.html - -COPY default.conf /etc/nginx/conf.d/ +RUN rm -f index.html && \ + ln -sf /usr/share/nginx/html/default.conf /etc/nginx/conf.d/default.conf COPY . . diff --git a/default.conf b/default.conf index 45123c1..193a08e 100644 --- a/default.conf +++ b/default.conf @@ -17,8 +17,9 @@ server { # see https://nginx.org/en/docs/http/ngx_http_charset_module.html for more details charset utf-8; + root /usr/share/nginx/html; + location / { - root /usr/share/nginx/html; index index.html index.htm; # customizations: @@ -29,17 +30,20 @@ server { add_header Vary Origin; } - # customization - like 1st location, but with `Content-Type` & `Content-Encoding` headers - location ~\.(js|wasm)\.gz$ { - root /usr/share/nginx/html; + # customization - like 1st location, but with `Content-Encoding` header + location ~ \.gz$ { add_header Access-Control-Allow-Origin *; add_header Access-Control-Allow-Methods GET,POST,OPTIONS; add_header Access-Control-Allow-Headers Accept-Encoding,Accept-Language,Authorization,Cache-Control,Content-Length,Content-Range,DNT,Pragma,Range,X-Requested-With; add_header Vary Origin; - types { } - default_type application/javascript; add_header Content-Encoding gzip; + + location ~ \.(js|wasm)\.gz$ { + # these files additionally need specific content type + types { } + default_type application/javascript; + } } error_page 500 502 503 504 /50x.html;