-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathnginx.conf
101 lines (80 loc) · 3.08 KB
/
nginx.conf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
events {
worker_connections 16;
}
http {
proxy_ssl_server_name on;
proxy_cache_path /server_cache levels=1:2 keys_zone=my_cache:10m max_size=1g inactive=4d use_temp_path=off;
log_format cache_log '$remote_addr - $remote_user [$time_local] '
'"$request" $status $body_bytes_sent '
'"$http_referer" "$http_user_agent" '
'Cache: $upstream_cache_status';
resolver 127.0.0.11 valid=30s;
resolver_timeout 5s;
server {
listen 80;
proxy_http_version 1.1;
proxy_set_header Host $host;
proxy_busy_buffers_size 512k;
proxy_buffers 4 512k;
proxy_buffer_size 256k;
# default endpoints (openai)
location ~* ^\/v1\/((engines\/.+\/)?(?:chat\/completions|completions|edits|moderations|answers|embeddings))$ {
proxy_set_header Host api.openai.com;
proxy_pass https://api.openai.com;
include cache.conf;
}
location /v1/(.*) {
proxy_set_header Host api.openai.com;
proxy_pass https://api.openai.com;
include cache.conf;
}
# provider specific endpoints
location ~* ^/openai/(.*)?$ {
proxy_set_header Host api.openai.com;
proxy_pass https://api.openai.com/$1;
include cache.conf;
}
location ~* ^/openrouter/(.*)?$ {
proxy_set_header Host openrouter.ai;
proxy_pass https://openrouter.ai/api/$1;
include cache.conf;
}
location ~* ^/anthropic/(.*)?$ {
proxy_set_header Host api.anthropic.com;
proxy_pass https://api.anthropic.com/$1;
include cache.conf;
}
# !! endpoints bellow are untested !!
location ~* ^/google/(.*)?$ {
proxy_set_header Host generativelanguage.googleapis.com;
proxy_pass https://generativelanguage.googleapis.com/v1beta/$1;
include cache.conf;
}
location ~* ^/cohere/(.*)?$ {
proxy_set_header Host api.cohere.ai;
proxy_pass https://api.cohere.ai/$1;
include cache.conf;
}
location ~* ^/ai21/(.*)?$ {
proxy_set_header Host api.ai21.com;
proxy_pass https://api.ai21.com/studio/$1;
include cache.conf;
}
location ~* ^/mistral/(.*)?$ {
proxy_set_header Host api.mistral.ai;
proxy_pass https://api.mistral.ai/$1;
include cache.conf;
}
# Note: Azure OpenAI and Amazon Bedrock are not included as they require specific resource names or regions
location ~* ^/huggingface/(.*)?$ {
proxy_set_header Host api-inference.huggingface.co;
proxy_pass https://api-inference.huggingface.co/models/$1;
include cache.conf;
}
location ~* ^/together/(.*)?$ {
proxy_set_header Host api.together.xyz;
proxy_pass https://api.together.xyz/$1;
include cache.conf;
}
}
}