diff --git a/gogongxt.com b/gogongxt.com index b12081b..3330d43 100644 --- a/gogongxt.com +++ b/gogongxt.com @@ -1,22 +1,59 @@ +# gogongxt.com · TLS reverse proxy in front of the noteflow container +# +# Container: ghcr.io/gogongxt/noteflow:0.3.0 published on 127.0.0.1:8080 +# +# The container sends the site's CSP and cache policy itself. Do NOT add a +# second Content-Security-Policy here: browsers enforce every CSP header they +# receive, so a stale extra policy would block the site's hashed inline +# scripts and styles. This file adds only HSTS, gzip, and the old-URL 301s. + server { listen 80; + listen [::]:80; + server_name gogongxt.com; + return 301 https://$host$request_uri; +} + +server { + listen 443 ssl http2; # nginx 1.24 — no separate `http2 on;` server_name gogongxt.com; - root /home/gogongxt/blog/public; - index index.html; + ssl_certificate /etc/letsencrypt/live/gogongxt.com/fullchain.pem; + ssl_certificate_key /etc/letsencrypt/live/gogongxt.com/privkey.pem; + ssl_protocols TLSv1.2 TLSv1.3; + server_tokens off; - # 静态文件直接返回 - location / { - try_files $uri $uri/ =404; + # The one security header the container cannot send (it is plain http). + add_header Strict-Transport-Security "max-age=31536000; includeSubDomains" always; + + # The container serves uncompressed; gzip before the bytes hit the wire. + gzip on; + gzip_comp_level 6; + gzip_min_length 1024; + gzip_vary on; + gzip_proxied any; + gzip_types text/plain text/css text/xml application/xml application/json + image/svg+xml application/javascript text/javascript application/rss+xml; + + # Old note URLs were /posts/.html; notes are now directories. + location ~ ^/posts/([^/]+)\.html$ { + return 301 /posts/$1; } - # Python API 反向代理 - # location /api/ { - # proxy_pass http://127.0.0.1:8000; - # } + # Hexo's feed path, if any reader still uses it. + location = /atom.xml { + return 301 /feed.xml; + } - listen 443 ssl; - - ssl_certificate /etc/letsencrypt/live/gogongxt.com/fullchain.pem; - ssl_certificate_key /etc/letsencrypt/live/gogongxt.com/privkey.pem; + location / { + proxy_pass http://127.0.0.1:8080; + 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; + # Range seeks in