输入命令
vi /etc/nginx/conf.d/openai-api.conf
粘贴如下内容
server {
listen your_port;
server_name your_server_ip;
location / {
proxy_pass https://api.openai.com/;
proxy_ssl_server_name on;
proxy_set_header Host api.openai.com;
proxy_set_header Connection '';
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_buffering off;
proxy_cache off;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_set_header X-Forwarded-Proto $scheme;
}
然后
nginx -s reload
在防火墙把端口开放即可!