server { listen 80; listen [::]:80; # server_name ai.takegpt.cn; access_log /data/wwwlogs/www.takegpt.cn_nginx.log combined; location / { proxy_pass https://api.openai.com; proxy_ssl_server_name on; # 开启代理SSL服务器名称验证,确保SSL连接的安全性 proxy_set_header Host api.openai.com; # 设置代理请求头中的Host字段为api.openai.com chunked_transfer_encoding off; # 禁用分块编码传输,避免可能的代理问题 proxy_buffering off; # 禁用代理缓存,避免数据传输延迟 proxy_cache off; # 禁用代理缓存,确保实时获取最新的数据 #proxy_set_header X-Forwarded-For $remote_addr; # 将客户端真实IP添加到代理请求头中的X-Forwarded-For字段中,用于记录客户端真实IP #include proxy.conf; } } server { listen 443 ssl http2; listen [::]:443 ssl http2; # server_name ai.takegpt.cn; ssl_certificate "/root/.acme.sh/takegpt.cn_ecc/fullchain.cer"; ssl_certificate_key "/root/.acme.sh/takegpt.cn_ecc/takegpt.cn.key"; ssl_session_cache shared:SSL:1m; ssl_session_timeout 10m; ssl_ciphers HIGH:!aNULL:!MD5; ssl_prefer_server_ciphers on; location / { proxy_pass https://api.openai.com; } error_page 404 /404.html; location = /40x.html { } error_page 500 502 503 504 /50x.html; location = /50x.html { } }