国外服务器,配置和带宽没要求,能跑nginx就行,线路不能太差不然体验不好(最好不是港澳台的,推荐美国)
Nginx配置
server { listen 80; server_name localhost; root html; location ^~ / { if ($request_method = 'OPTIONS') { return 204; } add_header Access-Control-Allow-Origin "*"; add_header Access-Control-Allow-Headers "Authorization,Cache-Control,Content-Type"; proxy_pass https://api.openai.com; proxy_set_header Host api.openai.com; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header Upgrade $http_upgrade; proxy_set_header Accept-Encoding ""; proxy_ssl_session_reuse off; proxy_ssl_server_name on; proxy_buffering off; proxy_max_temp_file_size 0; resolver 8.8.8.8 ipv6=off; resolver_timeout 10s; } }
宝塔控制面板配置如下
不建议开https,对速度有点影响。
# openai-API location ^~ / { if ($request_method = 'OPTIONS') { return 204; } add_header Access-Control-Allow-Origin "*"; add_header Access-Control-Allow-Headers "Authorization,Cache-Control,Content-Type"; proxy_pass https://api.openai.com; proxy_set_header Host api.openai.com; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header REMOTE-HOST $remote_addr; proxy_set_header Upgrade $http_upgrade; proxy_set_header Accept-Encoding ""; proxy_ssl_session_reuse off; proxy_ssl_server_name on; proxy_buffering off; proxy_max_temp_file_size 0; resolver 8.8.8.8 ipv6=off; resolver_timeout 10s; }
相关文章:
- [NGINX] – 配置文件优化 – NGINX.CONF
- nginx proxy_pass后的url加不加/的区别
- HTTP/3 原理实战
- Nginx Ngx_http_proxy_connect_module模块实现SSL正向代理