github-actions[bot] commited on
Commit
c7b1153
·
1 Parent(s): 748fffe

Update from GitHub Actions

Browse files
Files changed (4) hide show
  1. .coding-ci.yml +10 -0
  2. Dockerfile +51 -0
  3. app/index.html +132 -0
  4. nginx.conf +160 -0
.coding-ci.yml ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
 
1
+ main:
2
+ push:
3
+ - docker:
4
+ image: node:18
5
+ imports: https://godgodgame.coding.net/p/tools/d/oci-private-key/git/tree/master/envs.yml
6
+ stages:
7
+ - name: 环境检查
8
+ script: echo $GITHUB_TOKEN_GK && echo $GITHUB_TOKEN && node -v && npm -v
9
+ - name: 将master分支同步更新到github的master分支
10
+ script: git push https://$GITHUB_TOKEN_GK:[email protected]/zhezzma/nginx-proxy.git HEAD:main
Dockerfile ADDED
@@ -0,0 +1,51 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # 使用官方 nginx 镜像作为基础镜像
2
+ FROM nginx:alpine
3
+
4
+ # 安装基本工具
5
+ RUN apk add --no-cache curl
6
+
7
+ # 创建必要的目录并设置权限
8
+ RUN mkdir -p /var/cache/nginx/client_temp \
9
+ && mkdir -p /var/cache/nginx/proxy_temp \
10
+ && mkdir -p /var/cache/nginx/fastcgi_temp \
11
+ && mkdir -p /var/cache/nginx/uwsgi_temp \
12
+ && mkdir -p /var/cache/nginx/scgi_temp \
13
+ && mkdir -p /var/run \
14
+ && mkdir -p /var/log/nginx \
15
+ && mkdir -p /usr/share/nginx/html \
16
+ && touch /var/run/nginx.pid
17
+
18
+ # 确保 nginx 用户有权限访问这些目录
19
+ RUN chown -R nginx:nginx /var/cache/nginx \
20
+ && chown -R nginx:nginx /var/run \
21
+ && chown -R nginx:nginx /var/log/nginx \
22
+ && chown -R nginx:nginx /usr/share/nginx/html \
23
+ && chown -R nginx:nginx /etc/nginx/conf.d \
24
+ && chown -R nginx:nginx /etc/nginx/conf.d/default.conf \
25
+ && chown -R nginx:nginx /var/run/nginx.pid
26
+
27
+ RUN chmod -R 755 /var/cache/nginx \
28
+ && chmod -R 755 /var/run \
29
+ && chmod -R 755 /var/log/nginx \
30
+ && chmod -R 755 /usr/share/nginx/html \
31
+ && chmod -R 777 /etc/nginx/conf.d \
32
+ && chmod -R 777 /etc/nginx/conf.d/default.conf \
33
+ && chmod -R 777 /var/run/nginx.pid
34
+
35
+ # 复制 nginx 配置文件
36
+ COPY nginx.conf /etc/nginx/nginx.conf
37
+
38
+ # 复制网站文件(假设你的网站文件在 app 目录下)
39
+ COPY app/ /usr/share/nginx/html/
40
+
41
+ # 修改配置文件权限
42
+ RUN chown -R nginx:nginx /etc/nginx/nginx.conf
43
+
44
+ # 切换到非 root 用户
45
+ USER nginx
46
+
47
+ # 暴露80端口
48
+ EXPOSE 7860
49
+
50
+ # 启动nginx
51
+ CMD ["nginx", "-g", "daemon off;"]
app/index.html ADDED
@@ -0,0 +1,132 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <!DOCTYPE html>
2
+ <html>
3
+ <head>
4
+ <meta charset="utf-8">
5
+ <title>API Proxy Service</title>
6
+ <style>
7
+ * {
8
+ margin: 0;
9
+ padding: 0;
10
+ box-sizing: border-box;
11
+ font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
12
+ }
13
+
14
+ body {
15
+ background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
16
+ min-height: 100vh;
17
+ padding: 2rem;
18
+ }
19
+
20
+ .container {
21
+ max-width: 1200px;
22
+ margin: 0 auto;
23
+ background: white;
24
+ border-radius: 15px;
25
+ box-shadow: 0 10px 20px rgba(0,0,0,0.1);
26
+ padding: 2rem;
27
+ }
28
+
29
+ h1 {
30
+ color: #2c3e50;
31
+ text-align: center;
32
+ margin-bottom: 2rem;
33
+ font-size: 2.5rem;
34
+ }
35
+
36
+ .description {
37
+ text-align: center;
38
+ color: #666;
39
+ margin-bottom: 2rem;
40
+ }
41
+
42
+ table {
43
+ width: 100%;
44
+ border-collapse: collapse;
45
+ margin-top: 2rem;
46
+ background: white;
47
+ }
48
+
49
+ th, td {
50
+ padding: 1rem;
51
+ text-align: left;
52
+ border-bottom: 1px solid #eee;
53
+ font-size: 0.9rem;
54
+ }
55
+
56
+ th {
57
+ background: #f8f9fa;
58
+ color: #2c3e50;
59
+ font-weight: 600;
60
+ }
61
+
62
+ tr:hover {
63
+ background-color: #f8f9fa;
64
+ transition: all 0.3s ease;
65
+ }
66
+
67
+ .proxy-url {
68
+ color: #3498db;
69
+ }
70
+
71
+ .target-url {
72
+ color: #2ecc71;
73
+ }
74
+
75
+ @media (max-width: 768px) {
76
+ .container {
77
+ padding: 1rem;
78
+ }
79
+
80
+ th, td {
81
+ padding: 0.5rem;
82
+ font-size: 0.8rem;
83
+ }
84
+ }
85
+ </style>
86
+ </head>
87
+ <body>
88
+ <div class="container">
89
+ <h1>API 代理服务</h1>
90
+ <p class="description">为各大AI模型提供稳定可靠的代理服务</p>
91
+
92
+ <table>
93
+ <thead>
94
+ <tr>
95
+ <th>代理地址</th>
96
+ <th>目标地址</th>
97
+ </tr>
98
+ </thead>
99
+ <tbody>
100
+ <tr>
101
+ <td class="proxy-url">https://zhepama-nginx-proxy.hf.space/gemini/v1/{path}</td>
102
+ <td class="target-url">https://generativelanguage.googleapis.com/v1/{path}</td>
103
+ </tr>
104
+ <tr>
105
+ <td class="proxy-url">https://zhepama-nginx-proxy.hf.space/gemini/v1beta/{path}</td>
106
+ <td class="target-url">https://generativelanguage.googleapis.com/v1beta/{path}</td>
107
+ </tr>
108
+ <tr>
109
+ <td class="proxy-url">https://zhepama-nginx-proxy.hf.space/groq/openai/v1/{path}</td>
110
+ <td class="target-url">https://api.groq.com/openai/v1/{path}</td>
111
+ </tr>
112
+ <tr>
113
+ <td class="proxy-url">https://zhepama-nginx-proxy.hf.space/cohere/v1/{path}</td>
114
+ <td class="target-url">https://api.cohere.ai/v1/{path}</td>
115
+ </tr>
116
+ <tr>
117
+ <td class="proxy-url">https://zhepama-nginx-proxy.hf.space/xai/v1/{path}</td>
118
+ <td class="target-url">https://api.x.ai/v1/{path}</td>
119
+ </tr>
120
+ <tr>
121
+ <td class="proxy-url">https://zhepama-nginx-proxy.hf.space/mistral/v1/{path}</td>
122
+ <td class="target-url">https://api.mistral.ai/v1/{path}</td>
123
+ </tr>
124
+ <tr>
125
+ <td class="proxy-url">https://zhepama-nginx-proxy.hf.space/github/v1/{path}</td>
126
+ <td class="target-url">https://models.inference.ai.azure.com/{path}</td>
127
+ </tr>
128
+ </tbody>
129
+ </table>
130
+ </div>
131
+ </body>
132
+ </html>
nginx.conf ADDED
@@ -0,0 +1,160 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ worker_processes auto;
2
+
3
+ error_log /var/log/nginx/error.log warn;
4
+ pid /var/run/nginx.pid;
5
+
6
+ events {
7
+ worker_connections 1024;
8
+ }
9
+
10
+ http {
11
+ include /etc/nginx/mime.types;
12
+ default_type application/octet-stream;
13
+
14
+ log_format main '$remote_addr - $remote_user [$time_local] "$request" '
15
+ '$status $body_bytes_sent "$http_referer" '
16
+ '"$http_user_agent" "$http_x_forwarded_for"';
17
+
18
+ access_log /var/log/nginx/access.log main;
19
+
20
+ client_body_temp_path /var/cache/nginx/client_temp;
21
+ proxy_temp_path /var/cache/nginx/proxy_temp;
22
+ fastcgi_temp_path /var/cache/nginx/fastcgi_temp;
23
+ uwsgi_temp_path /var/cache/nginx/uwsgi_temp;
24
+ scgi_temp_path /var/cache/nginx/scgi_temp;
25
+
26
+ sendfile on;
27
+ keepalive_timeout 65;
28
+
29
+ # GZIP 压缩配置
30
+ gzip on;
31
+ gzip_disable "msie6";
32
+ gzip_vary on;
33
+ gzip_proxied any;
34
+ gzip_comp_level 6;
35
+ gzip_types text/plain text/css application/json application/javascript text/xml application/xml application/xml+rss text/javascript;
36
+
37
+ # 定义限速区域
38
+ limit_req_zone $binary_remote_addr zone=api_limit:10m rate=10r/m;
39
+
40
+ # 更新 SSL 配置
41
+ ssl_protocols TLSv1.2 TLSv1.3;
42
+ ssl_ciphers HIGH:!aNULL:!MD5;
43
+
44
+ # 优化 SSL 参数
45
+ ssl_prefer_server_ciphers on; # 优先使用服务器的密码套件
46
+ ssl_session_timeout 1d; # SSL 会话超时时间
47
+ ssl_session_cache shared:SSL:50m; # SSL 会话缓存
48
+ ssl_session_tickets off; # 禁用 session tickets
49
+
50
+ # 模拟 Chrome 的 ECDH 曲线
51
+ ssl_ecdh_curve X25519:prime256v1:secp384r1;
52
+
53
+ # 添加上游服务器 SSL 验证配置
54
+ proxy_ssl_protocols TLSv1.2 TLSv1.3;
55
+ proxy_ssl_ciphers HIGH:!aNULL:!MD5;
56
+ proxy_ssl_verify off; # 如果上游证书验证有问题,可以先关闭验证
57
+ proxy_ssl_server_name on; # 启用 SNI 支持
58
+
59
+ server {
60
+ listen 7860;
61
+ server_name localhost;
62
+
63
+ location / {
64
+ root /usr/share/nginx/html;
65
+ index index.html index.htm;
66
+ try_files $uri $uri/ /index.html;
67
+ }
68
+ # Gemini v1 路由
69
+ location /gemini/v1/ {
70
+ # 启用限速
71
+ limit_req zone=api_limit burst=20 nodelay;
72
+ limit_req_status 429;
73
+
74
+ proxy_pass https://generativelanguage.googleapis.com/v1/;
75
+ proxy_set_header Host generativelanguage.googleapis.com;
76
+ proxy_set_header X-Real-IP $remote_addr;
77
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
78
+ }
79
+
80
+ # Gemini v1beta 路由
81
+ location /gemini/v1beta/ {
82
+ # 启用限速
83
+ limit_req zone=api_limit burst=20 nodelay;
84
+ limit_req_status 429;
85
+
86
+ proxy_pass https://generativelanguage.googleapis.com/v1beta/;
87
+ proxy_set_header Host generativelanguage.googleapis.com;
88
+ proxy_set_header X-Real-IP $remote_addr;
89
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
90
+ }
91
+
92
+ # Groq OpenAI 路由
93
+ location /groq/openai/v1/ {
94
+ # 启用限速
95
+ limit_req zone=api_limit burst=20 nodelay;
96
+ limit_req_status 429;
97
+
98
+ proxy_pass https://api.groq.com/openai/v1/;
99
+ proxy_set_header Host api.groq.com;
100
+ proxy_set_header X-Real-IP $remote_addr;
101
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
102
+ }
103
+
104
+ # Cohere 路由
105
+ location /cohere/v1/ {
106
+ # 启用限速
107
+ limit_req zone=api_limit burst=20 nodelay;
108
+ limit_req_status 429;
109
+
110
+ proxy_pass https://api.cohere.ai/v1/;
111
+ proxy_set_header Host api.cohere.ai;
112
+ proxy_set_header X-Real-IP $remote_addr;
113
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
114
+ }
115
+
116
+ # XAI 路由
117
+ location /xai/v1/ {
118
+ # 启用限速
119
+ limit_req zone=api_limit burst=20 nodelay;
120
+ limit_req_status 429;
121
+
122
+ proxy_pass https://api.x.ai/v1/;
123
+ proxy_set_header Host api.x.ai;
124
+ proxy_set_header X-Real-IP $remote_addr;
125
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
126
+ }
127
+
128
+ # Mistral 路由
129
+ location /mistral/v1/ {
130
+ # 启用限速
131
+ limit_req zone=api_limit burst=20 nodelay;
132
+ limit_req_status 429;
133
+
134
+ proxy_pass https://api.mistral.ai/v1/;
135
+ proxy_set_header Host api.mistral.ai;
136
+ proxy_set_header X-Real-IP $remote_addr;
137
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
138
+ }
139
+
140
+ # GitHub 路由
141
+ location /github/v1/ {
142
+ # 启用限速
143
+ limit_req zone=api_limit burst=20 nodelay;
144
+ limit_req_status 429;
145
+
146
+ proxy_pass https://models.inference.ai.azure.com/;
147
+ proxy_set_header Host models.inference.ai.azure.com;
148
+ proxy_set_header X-Real-IP $remote_addr;
149
+ proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
150
+ }
151
+
152
+ # 错误页面配置
153
+ error_page 500 502 503 504 /50x.html;
154
+ location = /50x.html {
155
+ root /usr/share/nginx/html;
156
+ }
157
+ }
158
+ }
159
+
160
+