Files
blogsite/deploy/nginx/an.xiaoan.xyz.conf
T

86 lines
2.7 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# =========================================================
# an.xiaoan.xyz - 本地 origin Nginx(9001,HTTP)
#
# 公网链路:
# Browser -> 云端 Nginx 443 (TLS, 证书) -> frps:80
# -> frpc -> 本机 Nginx:9001 -> Gunicorn:8000 -> Django
#
# 注意:现有 frpc 的 blog_sit 代理是 type="http",所以本机 9001 必须是 HTTP。
# 如果你改成 type="https" / TCP,请把本文件改为 listen 9001 ssl 并使用证书。
# =========================================================
upstream an_xiaoan_app {
server 127.0.0.1:8000;
keepalive 16;
}
server {
listen 9001;
server_name an.xiaoan.xyz;
server_tokens off;
client_max_body_size 220m;
client_body_timeout 300s;
send_timeout 300s;
access_log /var/log/nginx/an.xiaoan.xyz.access.log;
error_log /var/log/nginx/an.xiaoan.xyz.error.log warn;
# 云端 Nginx 会传 X-Forwarded-Proto: https;若没有(例如直接访问本机),
# 也按 HTTPS 处理,因为公网入口固定是云端 443。
set $forwarded_proto $http_x_forwarded_proto;
if ($forwarded_proto = "") {
set $forwarded_proto https;
}
# AI 摘要流式接口:关闭缓冲,保证逐段到达浏览器
location = /digest/stream/ {
proxy_pass http://an_xiaoan_app;
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-Host $host;
proxy_set_header X-Forwarded-Proto $forwarded_proto;
proxy_set_header Connection "";
proxy_connect_timeout 10s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_buffering off;
proxy_cache off;
}
location /static/ {
alias /home/myserver/my-site/staticfiles/;
expires 30d;
access_log off;
}
location /media/ {
alias /home/myserver/my-site/media/;
expires 7d;
access_log off;
}
location / {
proxy_pass http://an_xiaoan_app;
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-Host $host;
proxy_set_header X-Forwarded-Proto $forwarded_proto;
proxy_set_header Connection "";
proxy_connect_timeout 10s;
proxy_read_timeout 300s;
proxy_send_timeout 300s;
proxy_request_buffering off;
}
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;
}