chatGPT代理服务器搭建
yum -y install wget
wget http://soft.vpser.net/lnmp/lnmp1.9-full.tar.gz
tar -zxvf lnmp1.9-full.tar.gz
cd lnmp1.9-full
./install.sh nginx
生成证书
cd /usr/local
mkdir secret
cd secret
openssl genrsa -out private.key 2048
openssl req -new -key private.key -out server.csr
openssl x509 -req -days 3650 -in server.csr -signkey private.key -out server.crt
修改nginx.conf内容为
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 443 ssl ; #监听端口号
server_name api.abc.com; #域名或服务器ip
proxy_read_timeout 240s; #设置超时时间
ssl_certificate /usr/local/secret/server.crt; #对应前面生成密钥的位置
ssl_certificate_key /usr/local/secret/private.key; #对应前面生成密钥的位置
#charset koi8-r;
#access_log logs/host.access.log main;
location /v1/ {
proxy_pass https://api.openai.com; # 反向代理到https://api.openai.com/这个地址
proxy_set_header Host api.openai.com; # 设置代理请求头中的Host字段为api.openai.com
proxy_ssl_server_name on; # 开启代理SSL服务器名称验证,确保SSL连接的安全性
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
chatGPT的接口地址换成:https://api.abc.com/v1/chat/completions 即可
yum -y install wget
wget http://soft.vpser.net/lnmp/lnmp1.9-full.tar.gz
tar -zxvf lnmp1.9-full.tar.gz
cd lnmp1.9-full
./install.sh nginx
生成证书
cd /usr/local
mkdir secret
cd secret
openssl genrsa -out private.key 2048
openssl req -new -key private.key -out server.csr
openssl x509 -req -days 3650 -in server.csr -signkey private.key -out server.crt
修改nginx.conf内容为
#user nobody;
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 443 ssl ; #监听端口号
server_name api.abc.com; #域名或服务器ip
proxy_read_timeout 240s; #设置超时时间
ssl_certificate /usr/local/secret/server.crt; #对应前面生成密钥的位置
ssl_certificate_key /usr/local/secret/private.key; #对应前面生成密钥的位置
#charset koi8-r;
#access_log logs/host.access.log main;
location /v1/ {
proxy_pass https://api.openai.com; # 反向代理到https://api.openai.com/这个地址
proxy_set_header Host api.openai.com; # 设置代理请求头中的Host字段为api.openai.com
proxy_ssl_server_name on; # 开启代理SSL服务器名称验证,确保SSL连接的安全性
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
chatGPT的接口地址换成:https://api.abc.com/v1/chat/completions 即可