45 lines
1.4 KiB
Plaintext
45 lines
1.4 KiB
Plaintext
# Nginx 反代配置示例(服务端 API)
|
|
# 使用方式:
|
|
# 1. 将本文件复制到 /etc/nginx/conf.d/jianli-api.conf
|
|
# 2. 把 api.example.com 替换为你的真实域名
|
|
# 3. 证书路径按 certbot 实际生成位置调整(见 README)
|
|
# 4. nginx -t && systemctl reload nginx
|
|
|
|
# HTTP 全部跳转 HTTPS
|
|
server {
|
|
listen 80;
|
|
server_name api.example.com;
|
|
return 301 https://$host$request_uri;
|
|
}
|
|
|
|
server {
|
|
listen 443 ssl;
|
|
http2 on;
|
|
server_name api.example.com;
|
|
|
|
# Let's Encrypt 证书(certbot --nginx 会自动填写)
|
|
ssl_certificate /etc/letsencrypt/live/api.example.com/fullchain.pem;
|
|
ssl_certificate_key /etc/letsencrypt/live/api.example.com/privkey.pem;
|
|
ssl_protocols TLSv1.2 TLSv1.3;
|
|
|
|
# JD 全文归档 / 简历内容可能较大
|
|
client_max_body_size 20m;
|
|
|
|
# 访问日志(排查风控/异常调用用)
|
|
access_log /var/log/nginx/jianli-api.access.log;
|
|
|
|
location / {
|
|
proxy_pass http://127.0.0.1:8000;
|
|
|
|
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;
|
|
|
|
# 心跳/长请求留足超时
|
|
proxy_connect_timeout 10s;
|
|
proxy_read_timeout 120s;
|
|
proxy_send_timeout 120s;
|
|
}
|
|
}
|