10 lines
4.1 KiB
XML
10 lines
4.1 KiB
XML
<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>代理方案 on FastGPT</title><link>https://doc.tryfastgpt.ai/docs/development/proxy/</link><description>Recent content in 代理方案 on FastGPT</description><generator>Hugo -- gohugo.io</generator><language>zh-cn</language><atom:link href="https://doc.tryfastgpt.ai/docs/development/proxy/index.xml" rel="self" type="application/rss+xml"/><item><title>Nginx 中转</title><link>https://doc.tryfastgpt.ai/docs/development/proxy/nginx/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://doc.tryfastgpt.ai/docs/development/proxy/nginx/</guid><description>登录 Sealos linkSealos
|
||
创建应用 link打开 「应用管理」,点击「新建应用」:
|
||
填写基本配置 link务必开启外网访问,复制外网访问提供的地址。
|
||
添加配置文件 link 复制下面这段配置文件,注意 server_name 后面的内容替换成第二步的外网访问地址。
|
||
user nginx; worker_processes auto; worker_rlimit_nofile 51200; events { worker_connections 1024; } http { resolver 8.8.8.8; proxy_ssl_server_name on; access_log off; server_names_hash_bucket_size 512; client_header_buffer_size 64k; large_client_header_buffers 4 64k; client_max_body_size 50M; proxy_connect_timeout 240s; proxy_read_timeout 240s; proxy_buffer_size 128k; proxy_buffers 4 256k; server { listen 80; server_name tgohwtdlrmer.cloud.sealos.io; # 这个地方替换成 Sealos 提供的外网地址 location ~ /openai/(.*) { proxy_pass https://api.openai.com/$1$is_args$args; proxy_set_header Host api.openai.com; proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; # 如果响应是流式的 proxy_set_header Connection &#39;&#39;; proxy_http_version 1.</description></item><item><title>HTTP 代理中转</title><link>https://doc.tryfastgpt.ai/docs/development/proxy/http_proxy/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://doc.tryfastgpt.ai/docs/development/proxy/http_proxy/</guid><description>如果你有代理工具(例如 Clash 或者 sing-box),也可以使用 HTTP 代理来访问 OpenAI。只需要添加以下两个环境变量即可:
|
||
AXIOS_PROXY_HOST= AXIOS_PROXY_PORT= 以 Clash 为例,建议指定 api.openai.com 走代理,其他请求都直连。示例配置如下:
|
||
mixed-port: 7890 allow-lan: false bind-address: &#39;*&#39; mode: rule log-level: warning dns: enable: true ipv6: false nameserver: - 8.8.8.8 - 8.8.4.4 cache-size: 400 proxies: - proxy-groups: - { name: &#39;♻️ 自动选择&#39;, type: url-test, proxies: [香港V01×1.5], url: &#39;https://api.openai.com&#39;, interval: 3600} rules: - &#39;DOMAIN-SUFFIX,api.openai.com,♻️ 自动选择&#39; - &#39;MATCH,DIRECT&#39; 然后给 FastGPT 添加两个环境变量:
|
||
AXIOS_PROXY_HOST=127.0.0.1 AXIOS_PROXY_PORT=7890</description></item><item><title>Cloudflare Worker 中转</title><link>https://doc.tryfastgpt.ai/docs/development/proxy/cloudflare/</link><pubDate>Mon, 01 Jan 0001 00:00:00 +0000</pubDate><guid>https://doc.tryfastgpt.ai/docs/development/proxy/cloudflare/</guid><description>参考 &ldquo;不做了睡觉&rdquo; 的教程
|
||
workers 配置文件
|
||
const TELEGRAPH_URL = &#39;https://api.openai.com&#39;; addEventListener(&#39;fetch&#39;, (event) =&gt; { event.respondWith(handleRequest(event.request)); }); async function handleRequest(request) { // 安全校验 if (request.headers.get(&#39;auth&#39;) !== &#39;auth_code&#39;) { return new Response(&#39;UnAuthorization&#39;, { status: 403 }); } const url = new URL(request.url); url.host = TELEGRAPH_URL.replace(/^https?:\/\//, &#39;&#39;); const modifiedRequest = new Request(url.toString(), { headers: request.headers, method: request.method, body: request.body, redirect: &#39;follow&#39; }); const response = await fetch(modifiedRequest); const modifiedResponse = new Response(response.body, response); // 添加允许跨域访问的响应头 modifiedResponse.</description></item></channel></rss> |