From d8b4bc33da91f00381bf22b4e997b2d315167210 Mon Sep 17 00:00:00 2001 From: Felix Date: Sun, 1 Jun 2025 03:34:22 +0200 Subject: [PATCH] i hate nginx --- docker-compose.yml | 12 ++++++++++++ nginx.conf | 33 ++++++++++++++++++++++++--------- 2 files changed, 36 insertions(+), 9 deletions(-) create mode 100644 docker-compose.yml diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..95515da --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,12 @@ +version: '3.8' + +services: + nginx: + image: nginx:alpine + container_name: website-nginx + ports: + - "8097:80" + volumes: + - /opt/docker/Website:/usr/share/nginx/html:ro + - ./nginx.conf:/etc/nginx/conf.d/default.conf:ro + restart: unless-stopped \ No newline at end of file diff --git a/nginx.conf b/nginx.conf index 226f4a6..ed6fca3 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,11 +1,26 @@ server { - listen 8097; - server_name localhost; - - root /usr/share/nginx/html; - index index.html; - - location / { - try_files $uri $uri/ /index.html; - } + listen 80; + server_name localhost; + + root /usr/share/nginx/html; + index index.html index.htm index.php; + + location / { + try_files $uri $uri/ =404; + } + + # Enable gzip compression + gzip on; + gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript; + + # Cache static assets + location ~* \.(css|js|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ { + expires 1y; + add_header Cache-Control "public, immutable"; + } + + # Security headers + add_header X-Frame-Options "SAMEORIGIN" always; + add_header X-Content-Type-Options "nosniff" always; + add_header X-XSS-Protection "1; mode=block" always; } \ No newline at end of file