Add Nginx deny config and server hardening scripts
Add new nginx/deny.conf to block unmatched hosts and explicitly close fukun.net. Remove Photoview icon hijacking, add client_max_body_size. Add scripts for deep inspection, disk monitoring, firewall setup, Gitea port confinement, and security updates.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
|
||||
# Block unmatched hosts
|
||||
server {
|
||||
listen 80;
|
||||
listen 443 ssl;
|
||||
ssl_certificate /etc/nginx/ssl/fukun.net_bundle.crt;
|
||||
ssl_certificate_key /etc/nginx/ssl/fukun.net.key;
|
||||
server_name _;
|
||||
return 444;
|
||||
}
|
||||
|
||||
# Explicitly close fukun.net
|
||||
server {
|
||||
listen 80;
|
||||
listen 443 ssl;
|
||||
server_name fukun.net www.fukun.net;
|
||||
ssl_certificate /etc/nginx/ssl/fukun.net_bundle.crt;
|
||||
ssl_certificate_key /etc/nginx/ssl/fukun.net.key;
|
||||
return 444;
|
||||
}
|
||||
@@ -12,11 +12,9 @@ server {
|
||||
ssl_certificate_key /etc/nginx/ssl/gallery.fukun.net.key;
|
||||
ssl_protocols TLSv1.2 TLSv1.3;
|
||||
ssl_ciphers HIGH:!aNULL:!MD5;
|
||||
# 劫持 Photoview 图标,统一用 fukun.net 的 favicon
|
||||
location = /photoview-logo.svg { root /home/hugo/hugo-blog/public; try_files /favicon.svg =404; }
|
||||
location = /logo192.png { root /home/hugo/hugo-blog/public; try_files /favicon-32x32.png =404; }
|
||||
location = /logo512.png { root /home/hugo/hugo-blog/public; try_files /favicon-32x32.png =404; }
|
||||
location = /manifest.json { root /home/hugo/hugo-blog/public; try_files /site.webmanifest =404; }
|
||||
|
||||
client_max_body_size 4G;
|
||||
|
||||
# favicon 统一走 fukun.net
|
||||
location = /favicon.ico { root /home/hugo/hugo-blog/public; }
|
||||
location = /favicon.png { root /home/hugo/hugo-blog/public; }
|
||||
@@ -27,19 +25,28 @@ server {
|
||||
location = /apple-touch-icon.png { root /home/hugo/hugo-blog/public; }
|
||||
location = /site.webmanifest { root /home/hugo/hugo-blog/public; }
|
||||
|
||||
client_max_body_size 4G;
|
||||
# 劫持 Photoview 图标
|
||||
location = /photoview-logo.svg { root /home/hugo/hugo-blog/public; try_files /favicon.svg =404; }
|
||||
location = /logo192.png { root /home/hugo/hugo-blog/public; try_files /favicon-32x32.png =404; }
|
||||
location = /logo512.png { root /home/hugo/hugo-blog/public; try_files /favicon-32x32.png =404; }
|
||||
location = /manifest.json { root /home/hugo/hugo-blog/public; try_files /site.webmanifest =404; }
|
||||
|
||||
# CORS — 允许 gallery.fukun.net 跨域请求(CDN 回源需要)
|
||||
add_header Access-Control-Allow-Origin "https://gallery.fukun.net" always;
|
||||
add_header Access-Control-Allow-Methods "GET, OPTIONS" always;
|
||||
add_header Access-Control-Allow-Headers "*" always;
|
||||
add_header Access-Control-Allow-Credentials "true" always;
|
||||
# 静态资源缓存(Photoview 直出,不经代理)
|
||||
location /assets/ {
|
||||
proxy_pass http://127.0.0.1:8000;
|
||||
proxy_http_version 1.1;
|
||||
proxy_set_header Host $host;
|
||||
expires 30d;
|
||||
add_header Cache-Control "public, immutable";
|
||||
}
|
||||
|
||||
# 相片直出(CDN 回源)
|
||||
location /photos/ {
|
||||
alias /home/gallery/photos/;
|
||||
add_header Access-Control-Allow-Origin "*" always;
|
||||
}
|
||||
|
||||
# Photoview
|
||||
location / {
|
||||
proxy_pass http://127.0.0.1:8000;
|
||||
proxy_http_version 1.1;
|
||||
|
||||
Reference in New Issue
Block a user