This commit is contained in:
Mateusz Gruszczyński
2026-04-13 08:25:14 +02:00
parent 53e7a70d31
commit 4ca10f3d9b
8 changed files with 134 additions and 99 deletions

View File

@@ -1,13 +1,3 @@
upstream backend_upstream {
server backend:8000;
keepalive 16;
}
map $uri $static_file {
~*\.(?:css|js|mjs|png|jpg|jpeg|gif|svg|ico|webp|woff2?)$ 1;
default 0;
}
server {
listen 80;
server_name _;
@@ -18,71 +8,7 @@ server {
root /usr/share/nginx/html;
index index.html;
#gzip on;
#gzip_comp_level 5;
#gzip_min_length 1024;
#gzip_types text/plain text/css text/javascript application/javascript application/json application/xml image/svg+xml;
add_header X-Content-Type-Options "nosniff" always;
add_header X-Frame-Options "SAMEORIGIN" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
add_header Permissions-Policy "geolocation=(), microphone=(), camera=()" always;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_set_header Connection "";
proxy_buffering off;
proxy_read_timeout 60s;
proxy_send_timeout 60s;
location ^~ /assets/ {
expires 7d;
add_header Cache-Control "public, max-age=604800, immutable" always;
try_files $uri =404;
}
location = /favicon.ico {
expires 7d;
add_header Cache-Control "public, max-age=604800" always;
try_files $uri =404;
}
location = /index.html {
add_header Cache-Control "no-store, no-cache" always;
try_files $uri =404;
}
location ^~ /api/ {
add_header Cache-Control "no-store, no-cache, must-revalidate" always;
add_header Pragma "no-cache" always;
proxy_pass http://backend_upstream/api/;
}
location = /docs {
add_header Cache-Control "no-store, no-cache, must-revalidate" always;
proxy_pass http://backend_upstream/docs;
}
location = /openapi.json {
add_header Cache-Control "no-store, no-cache, must-revalidate" always;
proxy_pass http://backend_upstream/openapi.json;
}
location = /redoc {
add_header Cache-Control "no-store, no-cache, must-revalidate" always;
proxy_pass http://backend_upstream/redoc;
}
location / {
try_files $uri $uri/ /index.html;
if ($static_file) {
add_header Cache-Control "max-age=600" always;
}
add_header Cache-Control "no-store, no-cache" always;
}
}