-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx.conf
More file actions
68 lines (55 loc) · 2.01 KB
/
nginx.conf
File metadata and controls
68 lines (55 loc) · 2.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events { worker_connections 1024; }
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
server_tokens off;
# gzip
gzip on;
gzip_comp_level 5;
gzip_min_length 1024;
gzip_types text/plain text/css application/javascript application/json application/xml image/svg+xml;
gzip_vary on;
# Strong caching for immutable assets; override for HTML
map $sent_http_content_type $cache_control_header {
default "public, max-age=31536000, immutable";
~*text/html "no-cache";
}
server {
listen 80 default_server;
listen [::]:80 default_server;
server_name _;
root /usr/share/nginx/html;
index index.html;
# Security headers
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;
add_header Cross-Origin-Opener-Policy same-origin always;
add_header Cross-Origin-Resource-Policy same-origin always;
# Serve static files
location / {
try_files $uri $uri/ /index.html;
}
# Set cache headers
location ~* \.(?:css|js|mjs|json|png|jpe?g|gif|ico|svg|webp|ttf|otf|woff2?)$ {
add_header Cache-Control $cache_control_header always;
try_files $uri =404;
}
# HTML: no-cache
location ~* \.(?:html)$ {
add_header Cache-Control "no-cache" always;
try_files $uri =404;
}
# Healthcheck
location = /healthz { return 200 'ok'; add_header Content-Type text/plain; }
}
}