adhfdshfdsf commited on
Commit
3e8af2d
·
verified ·
1 Parent(s): a9a9eb5

Update Dockerfile

Browse files
Files changed (1) hide show
  1. Dockerfile +36 -26
Dockerfile CHANGED
@@ -1,26 +1,36 @@
1
- FROM node:18-slim
2
- RUN echo "const http = require('http'); \
3
- const https = require('https'); \
4
- const server = http.createServer((req, res) => { \
5
- const isClaude = req.url.includes('messages') || req.headers['user-agent']?.toLowerCase().includes('anthropic'); \
6
- const targetHost = isClaude ? 'api.anthropic.com' : 'api.openai.com'; \
7
- const options = { \
8
- hostname: targetHost, \
9
- port: 443, \
10
- path: req.url, \
11
- method: req.method, \
12
- headers: { ...req.headers, host: targetHost }, \
13
- rejectUnauthorized: false \
14
- }; \
15
- const proxyReq = https.request(options, (proxyRes) => { \
16
- res.writeHead(proxyRes.statusCode, proxyRes.headers); \
17
- proxyRes.pipe(res); \
18
- }); \
19
- req.pipe(proxyReq); \
20
- proxyReq.on('error', (e) => { \
21
- res.statusCode = 500; \
22
- res.end(e.message); \
23
- }); \
24
- }); \
25
- server.listen(7860, () => console.log('Proxy running on 7860'));" > server.js
26
- CMD ["node", "server.js"]
 
 
 
 
 
 
 
 
 
 
 
1
+ FROM nginx:alpine
2
+ RUN echo 'server { \
3
+ listen 7860; \
4
+ server_name _; \
5
+ \
6
+ # Отключаем ВСЮ буферизацию \
7
+ proxy_buffering off; \
8
+ proxy_request_buffering off; \
9
+ proxy_cache off; \
10
+ \
11
+ # Настройки таймаутов \
12
+ proxy_connect_timeout 60s; \
13
+ proxy_send_timeout 600s; \
14
+ proxy_read_timeout 600s; \
15
+ \
16
+ # Обработка OpenAI (Codex) \
17
+ location ~* ^/v1/(chat|completions|engines|models) { \
18
+ proxy_pass https://api.openai.com; \
19
+ proxy_set_header Host api.openai.com; \
20
+ proxy_ssl_server_name on; \
21
+ proxy_set_header X-Real-IP $remote_addr; \
22
+ proxy_set_header Connection ""; \
23
+ proxy_http_version 1.1; \
24
+ } \
25
+ \
26
+ # Обработка Anthropic (Claude) и всё остальное \
27
+ location / { \
28
+ proxy_pass https://api.anthropic.com/; \
29
+ proxy_set_header Host api.anthropic.com; \
30
+ proxy_ssl_server_name on; \
31
+ proxy_set_header X-Real-IP $remote_addr; \
32
+ proxy_set_header Connection ""; \
33
+ proxy_http_version 1.1; \
34
+ } \
35
+ }' > /etc/nginx/conf.d/default.conf
36
+ CMD ["nginx", "-g", "daemon off;"]