nginx反代ChatGPT

Nginx反代ChatGPT

1
2
3
4
5
6
7
8
9
location /v1/ {
proxy_pass https://api.openai.com/v1/;
proxy_redirect off;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
# 必须开启SNI,否则会404或502
proxy_ssl_server_name on;
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
}

否则会报错:SSL_do_handshake() failed (SSL: error:14077410:SSL routines:SSL23_GET_SERVER_HELLO:sslv3 alert handshake failure) while SSL handshaking to upstream

引用

  1. https://zhuanlan.zhihu.com/p/547260827
  2. https://en.wikipedia.org/wiki/Server_Name_Indication
  3. https://blog.csdn.net/jeccisnd/article/details/99300178