Published: 19 May 2025 › Updated: 19 May 2025
ClawCloud的Nginx反向代理做OpenAI API转发
做OpenAI API开发的小伙伴可以看看此篇。
做本地使用或是某些服务器上有限制,那么,用一台不受限的服务器做转发就是必备的。一直用的是伦敦的IP、Nginx反向代理做了转发。虽然还有些最新的大模型用不了,但基础模型如o1-mini,4o这些可以使用。
ClawCloud有免费的资源,能迁过来免费用么?能想到,那基本上就可以做到!试了几个参数就顺利开通了。
ClawCloud Run界面
新起一个 App lanchpad, 以下是参数
- image name: nginx
- 1 cpu 512M
- 打开 80 端口
- Configmaps添加两个Nginx设置
a./etc/nginx/nginx.conf
b./etc/nginx/conf.d/aiwork.conf
具体配置参考稍后的文本 - localstorage:
/etc/letsencrypt/
两个Nginx设置
a. /etc/nginx/nginx.conf
user nginx;
worker_processes auto;
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
}
http {
include /etc/nginx/mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
log_format upstreamlog '[$time_local] $remote_addr passed to: $upstream_addr: $request Upstream Response Time: $upstream_response_time Request time: $request_time';
access_log /var/log/nginx/access.log main;
sendfile on;
#tcp_nopush on;
keepalive_timeout 65;
#gzip on;
include /etc/nginx/conf.d/*.conf;
}
b. /etc/nginx/conf.d/aiwork.conf
server {
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;
}
}
这样就可以布署了!成功后,80端口对应的网址就是转发的地址, 点击打开后会有一行文本,如下
{
"message": "Welcome to the OpenAI API! Documentation ..."
}
有上面的信息就是成功转发啰!
开发时多设置一行参数即可:
const Openai = new OpenAI({
apiKey: apiKey,
baseURL: "https://yufepxxxxx.clawcloudrun.com/v1" //多加这行
})
Leave ClawCloud的Nginx反向代理做OpenAI API转发 to:
Read more #cn posts
Best Posts From lemooljiang
We have not curated any of lemooljiang's posts yet. But you can encourage our curation team to review posts by visiting them regularly and by referring other readers. Because we give priority to frequently read content.
More Posts From lemooljiang
- Nextjs初体验,和Nuxt的异同
- DeepTutor:AI个性化辅导平台 / ai #57
- ComfyUI:可编程和自动化的PS / ai #56
- 将Neo4j封装进Agent / ai #55
- 闲鱼省钱大法:极限0.5折!
- 对Neo4j批量导入结构化数据 / ai #54
- langchain对neo4j进行交互,写入和查询数据 / ai #53
- 知识图谱和图数据库Neo4j的作用和使用场景 / ai #52
- SpaceX、美股和比特币
- 又是币圈血洗日!
- 链股合流,当币安也开始卖股票啰
- 天涯社区重启,爷青回?
- 诺基亚在AI时代重新杀回来啦
- 《2049:未来10000天的可能》书中的镜像世界为什么不叫元宇宙
- 今天适合吃披萨
- 开通即被封,别再给Claude送人头了!
- 两根内存条引发的“官司”
- AI·Joe V12更新, 更新GPT-5.5和DeepSeek V4 等
- 中医进校园活动反响热烈
- 猪价低伤农,猪价贵伤民