-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnginx.conf.example
More file actions
71 lines (60 loc) · 1.92 KB
/
Copy pathnginx.conf.example
File metadata and controls
71 lines (60 loc) · 1.92 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 yourdomain.com www.yourdomain.com;
root /var/www/seriously;
index aggregated_feed.html;
# SSL — uncomment after certbot setup
# listen 443 ssl;
# ssl_certificate /etc/letsencrypt/live/yourdomain.com/fullchain.pem;
# ssl_certificate_key /etc/letsencrypt/live/yourdomain.com/privkey.pem;
# if ($scheme = http) { return 301 https://$host$request_uri; }
# ── Routes ──
# Admin page
location = /admin {
try_files /admin.html =404;
}
# Atom feed
location = /feed {
rewrite ^ /api.php?action=feed last;
}
# Legacy WordPress — kill wp-* asset requests
location ~ ^/wp-(content|admin|json|includes)/ {
return 410;
}
# Legacy WordPress — redirect category/author/tag/date URLs to search
location ~ ^/category/(.+?)/?$ {
return 301 /?q=$1;
}
location ~ ^/author/(.+?)/?$ {
return 301 /?q=$1;
}
location ~ ^/tag/(.+?)/?$ {
return 301 /?q=$1;
}
location ~ ^/\d{4}/\d{2}/\d{2}/(.+?)/?$ {
return 301 /?q=$1;
}
# ── PHP ──
location ~ \.php$ {
include snippets/fastcgi-params.conf;
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# ── Security ──
# Block sensitive files
location ~ \.(env|json|py|md|sh)$ {
# Allow api.php to read these server-side — just block direct web access
return 403;
}
# Allow feed_data.json for api.php (internal only)
location = /api.php {
include snippets/fastcgi-params.conf;
fastcgi_pass unix:/run/php/php-fpm.sock;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
# Cache static assets
location ~* \.(css|js|woff2|png|jpg|ico|svg)$ {
expires 7d;
add_header Cache-Control "public, immutable";
}
}