From e3aec943e00b185097e6aad1771e4af6724c5329 Mon Sep 17 00:00:00 2001 From: Benno Lorenz Date: Sun, 1 Jun 2025 22:30:53 +0200 Subject: [PATCH] updated nginx conf for cms --- nginx.conf | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/nginx.conf b/nginx.conf index a551172..d9e41db 100644 --- a/nginx.conf +++ b/nginx.conf @@ -1,10 +1,24 @@ server { listen 80; - server_name localhost; + server_name localhost; # This is fine as Traefik handles the external domain root /usr/share/nginx/html; - + + # Specific location for the Decap CMS admin panel + # This ensures that any request to /admin/ or /admin/* (that isn't an existing file/dir) + # serves /admin/index.html, allowing Decap's client-side router to work. + location /admin/ { + try_files $uri $uri/ /admin/index.html; + } + + # General location block for the rest of your site location / { - index index.html; - try_files $uri $uri/ =404; + index index.html; # Serves index.html from directories + try_files $uri $uri/ =404; # Returns 404 if file/directory not found. + # If your main site is also an SPA, change to: try_files $uri $uri/ /index.html; + } + + # Optional: Deny access to hidden files like .htaccess or .git + location ~ /\. { + deny all; } }