我是一个nginx转发服务器,2个应用服务器做的测试。
这只是一个我实现的一种方式,大佬勿喷!
nginx 服务器上的配置:(nginx加上ssl,其他的用端口,我用域名会出现跨域报错)
http {
upstream backend {
server ip1:port;
server ip2:port;
}
server
{
listen 80;
listen 443 ssl http2;
server_name *.*.域名;
index index.php index.html index.htm default.php default.htm default.html;
root /www/wwwroot/ *.*.域名;
#________________其他配置___________
# 页面只转发,就使用下面
location ^~ /log/ {
proxy_pass http://backend;
client_max_body_size 64m;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_cache_bypass $http_upgrade;
proxy_set_header Accept-Encoding gzip;
proxy_read_timeout 300s; # GPT-4 需要较长的超时时间,请自行调整
}
location ~* ^/(v1|mj|api)/ {
proxy_pass http://backend;
client_max_body_size 64m;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $remote_addr;
proxy_cache_bypass $http_upgrade;
proxy_set_header Accept-Encoding gzip;
proxy_read_timeout 300s; # GPT-4 需要较长的超时时间,请自行调整
}
location ~* ^/user/reset {
proxy_pass http://backend; # 允许充值密码的连接访问
}
location / {
default_type text/plain;
return 200 '{"message": "Welcome to the OpenAI API! Documentation is available at https://platform.openai.com/docs/api-reference"}';
}
# 不使用只转发的方式,都要访问页面,就使用
location / {
proxy_pass http://backend;
# 其他的代理设置...
}
#其他配置
}
其他服务器上,需要页面访问的才部署域名,其他的用端口就行了。