mirror of
https://github.com/kogakure/website-11ty-kogakure.de.git
synced 2026-02-03 12:15:28 +00:00
feat: add custom nginx configuration
This commit is contained in:
@@ -16,6 +16,12 @@ RUN pnpm run build
|
||||
# Stage 2: Serve the application using Nginx
|
||||
FROM nginx:stable-alpine
|
||||
|
||||
# Remove the default nginx.conf
|
||||
RUN rm /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Copy custom nginx configuration
|
||||
COPY ./nginx.conf /etc/nginx/conf.d/default.conf
|
||||
|
||||
# Copy build artifacts from the builder stage
|
||||
COPY --from=builder /app/dist /usr/share/nginx/html
|
||||
|
||||
|
||||
33
nginx.conf
Normal file
33
nginx.conf
Normal file
@@ -0,0 +1,33 @@
|
||||
server {
|
||||
listen 80;
|
||||
listen [::]:80;
|
||||
server_name localhost;
|
||||
|
||||
location / {
|
||||
root /usr/share/nginx/html;
|
||||
index index.html index.htm;
|
||||
}
|
||||
|
||||
# Error 404
|
||||
error_page 404 /404.html;
|
||||
|
||||
# General headers applied to all routes
|
||||
add_header X-Frame-Options "DENY";
|
||||
add_header X-XSS-Protection "1; mode=block";
|
||||
add_header X-Content-Type-Options "nosniff";
|
||||
add_header Referrer-Policy "no-referrer-when-downgrade";
|
||||
add_header Permissions-Policy "interest-cohort=()";
|
||||
|
||||
# Special handling for /sw.js
|
||||
location = /sw.js {
|
||||
add_header cache-control "max-age=0, no-cache, no-store, must-revalidate";
|
||||
}
|
||||
|
||||
# Redirects
|
||||
location ~ ^/artikel/(.*)$ {
|
||||
return 301 /$1;
|
||||
}
|
||||
|
||||
# Handling missing pages
|
||||
try_files $uri $uri/ /index.html;
|
||||
}
|
||||
Reference in New Issue
Block a user