nginx openai cache proxy (http监听,https上游)在docker中

使用docker,我正在尝试设置一个本地反向代理,其中包括以下内容:

  • 以http模式监听(我这里不需要加密
  • 将请求重定向到https服务器

这是为了缓存对openai的昂贵请求的目的。

我使用以下配置:

events {    worker_connections 10;}http {    proxy_cache_path /server_cache levels=1:2 keys_zone=my_cache:10m max_size=1g inactive=60m use_temp_path=off;    server {        listen 80;        location /v1/chat/completions {            proxy_pass https://api.openai.com;            proxy_cache my_cache;            proxy_cache_methods POST;            proxy_cache_key "$request_method$request_uri$request_body";            proxy_cache_valid 200 60m;            proxy_cache_valid 404 1m;            proxy_cache_use_stale error timeout updating http_500 http_502 http_503 http_504;            proxy_cache_background_update on;            proxy_cache_lock on;            proxy_set_header Host $host;        }        location / {            proxy_pass https://api.openai.com;            proxy_set_header Host $host;        }    }}

然而,每当它处理请求时,我从nginx日志中得到这个错误:

[error] 24#24: *1 SSL_do_handshake() failed (SSL: error:14094410:SSL routines:ssl3_read_bytes:sslv3 alert handshake failure:SSL alert number 40) while SSL handshaking to upstream

我读到我需要添加一些proxy_ssl_*指令并包含一些私钥…

但为什么当我设置的服务器是http而不是https时,我必须这样做呢?而且当我直接连接到上游https服务器时,我从不需要指定任何类型的证书(更不用说私钥了,这没有意义)。

有什么解决方案吗?这是nginx的缺陷吗?


回答:

有人提到添加

proxy_ssl_server_name on;

在你的location块中。你试过这个吗?

否则,如果你想将http代理到https,我听说人们通常建议使用haproxy代替。

Related Posts

使用LSTM在Python中预测未来值

这段代码可以预测指定股票的当前日期之前的值,但不能预测…

如何在gensim的word2vec模型中查找双词组的相似性

我有一个word2vec模型,假设我使用的是googl…

dask_xgboost.predict 可以工作但无法显示 – 数据必须是一维的

我试图使用 XGBoost 创建模型。 看起来我成功地…

ML Tuning – Cross Validation in Spark

我在https://spark.apache.org/…

如何在React JS中使用fetch从REST API获取预测

我正在开发一个应用程序,其中Flask REST AP…

如何分析ML.NET中多类分类预测得分数组?

我在ML.NET中创建了一个多类分类项目。该项目可以对…

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注