Skip to content

Commit

Permalink
updated nginx to be easier to hotswap check config changes and be lik…
Browse files Browse the repository at this point in the history
…e emularity-engine
  • Loading branch information
traceypooh committed Apr 9, 2024
1 parent 8053060 commit 1fbe6f1
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 9 deletions.
5 changes: 2 additions & 3 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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 . .
16 changes: 10 additions & 6 deletions default.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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;
Expand Down

0 comments on commit 1fbe6f1

Please sign in to comment.