server { listen 80; listen [::]:80; server_name lzwlab.cn www.lzwlab.cn; return 301 https://$host$request_uri; } server { listen 443 ssl http2; listen [::]:443 ssl http2; server_name lzwlab.cn www.lzwlab.cn; ssl_certificate /etc/nginx/ssl/lzwlab.cn_bundle.crt; ssl_certificate_key /etc/nginx/ssl/lzwlab.cn.key; ssl_protocols TLSv1.2 TLSv1.3; ssl_session_cache shared:SSL:10m; ssl_session_timeout 10m; root /var/www/lzwlab.cn; index index.html; location / { try_files $uri $uri/ =404; } # 文件快传应用:/transfer/ 反代到本机 8090 端口(Flask + gunicorn) location = /transfer { return 301 /transfer/; } location /transfer/ { proxy_pass http://127.0.0.1:8090/; 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; proxy_request_buffering off; proxy_buffering off; proxy_read_timeout 3600s; proxy_send_timeout 3600s; client_max_body_size 5120m; } # Gitea Git 服务:/git/ 反代到本机 3000 端口(Docker 容器) # 子路径方案参考 https://docs.gitea.com/administration/reverse-proxies/ 的 "Nginx with a sub-path" location ~ ^/(git)($|/) { client_max_body_size 512M; # 保持 "%2F" 原样,去掉 "/git" 前缀后转发给 Gitea rewrite ^ $request_uri; rewrite ^/(git($|/))?(.*) /$3 break; proxy_pass http://127.0.0.1:3000$uri; proxy_http_version 1.1; proxy_set_header Connection $http_connection; proxy_set_header Upgrade $http_upgrade; 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_read_timeout 300s; } }