From f368bf2de5f2b35296023b51b31480f36659372a Mon Sep 17 00:00:00 2001 From: Nathan Woodburn Date: Sat, 30 Sep 2023 12:36:11 +1000 Subject: [PATCH] nginx: Disable .git dir --- Dockerfile | 3 ++- nginx.conf | 24 ++++++++++++++++++++++++ 2 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 nginx.conf diff --git a/Dockerfile b/Dockerfile index fe90322..4c50f98 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,3 +1,4 @@ FROM nginx:alpine COPY . /usr/share/nginx/html -COPY ./assets/img/favicon.png /usr/share/nginx/html \ No newline at end of file +COPY ./assets/img/favicon.png /usr/share/nginx/html +COPY ./nginx.conf /etc/nginx/conf.d/default.conf \ No newline at end of file diff --git a/nginx.conf b/nginx.conf new file mode 100644 index 0000000..470b009 --- /dev/null +++ b/nginx.conf @@ -0,0 +1,24 @@ +server { + listen 80; + listen [::]:80; + server_name localhost; + + location / { + root /usr/share/nginx/html; + index index.html index.htm; + try_files $uri $uri.html $uri/ =404; + } + + location ~ /\.git { + deny all; + access_log off; + log_not_found off; + } + + # Custom 404 page + error_page 404 /404.html; + location = /404.html { + } + +} +