Skip to content

Instantly share code, notes, and snippets.

@lewangdev
Created November 11, 2023 13:20
Show Gist options
  • Save lewangdev/a0383640e55482d726908a1a40e4ca21 to your computer and use it in GitHub Desktop.
Save lewangdev/a0383640e55482d726908a1a40e4ca21 to your computer and use it in GitHub Desktop.
nginx proxy for openai api
server {
listen 80;
server_name openai-api.xxx.link;
error_log /var/log/nginx/openai-api/nginx-error.log;
access_log /var/log/nginx/openai-api/nginx-access.log main;
return 301 https://$host$request_uri;
}
server {
listen 443 ssl;
server_name openai-api.xxx.link;
error_log /var/log/nginx/openai-api/nginx-error-ssl.log;
access_log /var/log/nginx/openai-api/nginx-access-ssl.log main;
ssl_certificate /data/acme.sh/xxx.link/fullchain.cer;
ssl_certificate_key /data/acme.sh/xxx.link/bi83.link.key;
include /etc/nginx/ssl/options-ssl-nginx.conf;
ssl_dhparam /etc/nginx/ssl/ssl-dhparam.pem;
ignore_invalid_headers off;
client_max_body_size 0;
proxy_buffering off;
location /v1/audio/speech {
proxy_pass https://api.openai.com/v1/audio/speech;
proxy_ssl_name api.openai.com;
proxy_ssl_server_name on;
# Forward all headers
proxy_pass_request_headers on;
# proxy_http_version 1.1;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment