From 21169b9e55e2a278acc858d0e932bd571301ec3a Mon Sep 17 00:00:00 2001 From: Louis Vallat Date: Thu, 16 Jun 2022 10:54:48 +0200 Subject: [PATCH] fix: added custom nginx configuration to have gzip compression and cache control Signed-off-by: Louis Vallat --- Dockerfile | 3 ++- nginx.conf | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index 4a975c6..d5558f5 100644 --- a/Dockerfile +++ b/Dockerfile @@ -2,5 +2,6 @@ FROM nginx:latest EXPOSE 80 -COPY . /usr/share/nginx/html/ +COPY ./src/ /usr/share/nginx/html/ +COPY ./nginx.conf /etc/nginx/conf.d/default.conf diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..0e5c5a3 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,24 @@ +server { + listen 80; + server_name localhost; + + gzip on; + gzip_types text/plain application/xml; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + } + + location ~*.(js|css|ico)$ { + root /usr/share/nginx/html; + expires 2d; + add_header Cache-Control "public, no-transform"; + } + + location ~*.(ttf|png|jpg|jpeg|gif)$ { + root /usr/share/nginx/html; + expires 1y; + add_header Cache-Control "public, no-transform"; + } +}