-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx.conf
More file actions
71 lines (60 loc) · 1.75 KB
/
nginx.conf
File metadata and controls
71 lines (60 loc) · 1.75 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
67
68
69
70
71
server {
listen 80;
server_name _;
port_in_redirect off;
absolute_redirect off;
root /usr/share/nginx/html;
# Security headers (most are already in HTML, but good to have at server level too)
add_header X-Frame-Options "DENY" always;
add_header X-Content-Type-Options "nosniff" always;
add_header Referrer-Policy "strict-origin-when-cross-origin" always;
# Gzip compression
gzip on;
gzip_vary on;
gzip_min_length 1024;
gzip_types text/plain text/css text/xml text/javascript application/javascript application/xml+rss application/json;
# Cache static assets
location ~* \.(js|css|png|jpg|jpeg|gif|ico|svg|woff|woff2|ttf|eot)$ {
expires 1y;
add_header Cache-Control "public, immutable";
}
# HTML files - shorter cache
location ~* \.html$ {
expires 1h;
add_header Cache-Control "public, must-revalidate";
}
# Main location block
location / {
try_files $uri $uri/ $uri/index.html =404;
}
# Special handling for mathnotes section
location /mathnotes/ {
try_files $uri $uri/ $uri/index.html /mathnotes/$uri/index.html =404;
}
# Error pages
error_page 404 /404/index.html;
location = /404/index.html {
internal;
}
# Sitemap
location = /sitemap.xml {
expires 1d;
add_header Cache-Control "public, must-revalidate";
}
# Robots.txt
location = /robots.txt {
expires 7d;
add_header Cache-Control "public";
}
# Favicon
location = /favicon.ico {
expires 30d;
add_header Cache-Control "public";
}
# Disable access to hidden files
location ~ /\. {
deny all;
access_log off;
log_not_found off;
}
}