update
This commit is contained in:
@@ -0,0 +1,59 @@
|
||||
---
|
||||
title: 2023年干了啥?
|
||||
tags:
|
||||
- 2023
|
||||
- 2024
|
||||
- 年度总结
|
||||
ategories:
|
||||
- 年度总结
|
||||
index_img: /img/2024/1/1/2024.png
|
||||
banner_img: /img/2024/1/1/2024.png
|
||||
permalink: /2024/01/01/2023/index.html
|
||||
date: 2024-01-01 15:43:55
|
||||
---
|
||||
2023年,对我来说是很又趣的一年,在这一年,我开始真正的接触互联网并了解它。
|
||||
|
||||
## 今年干了啥
|
||||
|
||||
### 1-2月
|
||||
在1月左右,我收到了一台华为家庭存储,成为后续折腾的存储及备份系统。
|
||||
再往后几天,我在我的房间里接起了一台电脑机箱,正式开始了...额...这个...反正就是这方面的折腾吧,在我过往的文章中也可以看出来.
|
||||
如果你翻到本站的最下方,就会知道这个折腾的过程相当难受,在弄这些之前,我几乎没什么这方面的经历,只是几年前折腾过一段时间树莓派,当时很想将树莓派打造成一台NAS服务器,但由于当时啥也不懂,最终也没有折腾成功。所以在拿到机器后很短一段时间后就装上了alist。
|
||||
|
||||
### 3-5月
|
||||
* 在三月,因为对这方面起了兴趣,试用了一台阿里云ECS,2c4G,当时也不知道干什么,在群里和同学聊天时脑子一热便说我要搭个我的世界服务器,就开始研究怎么搞,过程就不说了,反正是成功了.
|
||||
* 陈皓 R.I.P.
|
||||
* 收到DJI AIR2S
|
||||
* 学会使用FRP建站,初代blog使用wordpress
|
||||
* 购买域名mei232.top并很快废弃
|
||||
|
||||
### 6月
|
||||
历史生物中考,啥也没干,考的还行,老师说如果其它科考好点有机会上重点高中,不过我也不指望上。
|
||||
|
||||
### 7-8月
|
||||
* 重庆-成都-遵义-大理航拍&指南.
|
||||
* 购买mmeiblog.cn域名,本站正式上线,一开始使用Zblog,后在8月改用halo
|
||||
* 开始学习前端及PHP.
|
||||
|
||||
### 9-11月
|
||||
* 雨云代理赚了几块钱
|
||||
* 猫猫云mc公益服务器上线
|
||||
* 累计感冒4次,其中两周连着感染两种病毒(24.1.14附:时隔两周,又感冒了,一学期感冒5次)
|
||||
* 更换blog系统为Hexo,决定永久删除评论系统
|
||||
|
||||
### 12月
|
||||
* 进一步完善blog细节,屏蔽百度蜘蛛并对带有百度Referer的用户进行劝解
|
||||
* 永久移除blog友链申请系统
|
||||
* 计划删除blog中的一切没良心的推广内容
|
||||
* 自建内容分发网络基本成型
|
||||
* 降本增效ing.
|
||||
|
||||
## 一些决定
|
||||
在三月份得知陈皓死讯后(那是我第一次知道这个人),我十分喜爱酷壳网coolshell.cn的模式,本站也受了酷壳相当大的影响。在一些地方想要模仿酷壳,也希望不要出现酷壳的遗憾。
|
||||
* 为什么永久移除评论系统?
|
||||
这要从为什么用Hexo说起了,一是因为占用性能少,加载快;二是最重要的一点---保存方便,在人死后可以很方便的留存相当长,若是仔细检查本站源代码就会发现,除了css和部分js使用了国内加速CDN外,就没有其它链接了。就可以放在静态网站托管平台相当长的时间。而评论显然不可能存在这么久.
|
||||
最正确的决定:彻底远离字节跳动等短视频平台,远离了某些作孽的"科技"企业后,感觉舒服了不少,再也没有恶心人的视频和造谣的人来恶心我了。
|
||||
|
||||
## 2024?
|
||||
2024年,因为有中考和高中可能的住校,更新肯定会缓慢不少
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
---
|
||||
title: 搭建自己的openai api高速反向代理
|
||||
tags:
|
||||
- AI
|
||||
- proxy
|
||||
categories:
|
||||
- AI
|
||||
index_img: /img/2024/1/25/openai.jpg
|
||||
banner_img: /img/2024/1/25/openai.jpg
|
||||
permalink: /2024/01/25/202401250927/index.html
|
||||
date: 2024-01-25 09:27:45
|
||||
---
|
||||
在去年(2023年),我看到了极客湾的这个视频:[我们做了个能对话的AI派蒙,免费给大家玩!](https://b23.tv/Ap27xLS)
|
||||
觉得很有意思,但是由于没有显卡且不敢翻墙,一直没有机会尝试,但最近搞来了一块RTX A2000(目前这卡性价比很低,不推荐),便想着折腾一下
|
||||
由于不敢翻墙,只能使用反向代理的方式来访问openai api
|
||||
## 准备
|
||||
你需要:
|
||||
* 一个Cloudflare账户
|
||||
* Cloudflare账户中有未被墙的有效域名(若有下一项,则为可选项)
|
||||
* 一台高速的非中国大陆服务器(配置不用太高,可选)(若无此项,则上一项为必选)
|
||||
* 一个好用的脑子
|
||||
|
||||
## Cloudflare worker
|
||||
创建一个Cloudflare worker,并把一下代码塞入其中(代码来自[这里](https://gitee.com/GoGPTAI/ChatGPT-Proxy))
|
||||
|
||||
```
|
||||
const TELEGRAPH_URL = 'https://api.openai.com';
|
||||
|
||||
addEventListener('fetch', event => {
|
||||
event.respondWith(handleRequest(event.request))
|
||||
})
|
||||
|
||||
async function handleRequest(request) {
|
||||
const url = new URL(request.url);
|
||||
url.host = TELEGRAPH_URL.replace(/^https?:\/\//, '');
|
||||
|
||||
const modifiedRequest = new Request(url.toString(), {
|
||||
headers: request.headers,
|
||||
method: request.method,
|
||||
body: request.body,
|
||||
redirect: 'follow'
|
||||
});
|
||||
|
||||
const response = await fetch(modifiedRequest);
|
||||
const modifiedResponse = new Response(response.body, response);
|
||||
|
||||
// 添加允许跨域访问的响应头
|
||||
modifiedResponse.headers.set('Access-Control-Allow-Origin', '*');
|
||||
|
||||
return modifiedResponse;
|
||||
}
|
||||
```
|
||||
使用Cloudflare理论上可以降低被封的概率
|
||||
由于workers.dev被墙了,所以需要在“触发器”中换用你的域名(如果有非中国大陆服务器则可以跳过这一步)
|
||||
如果你没有非中国大陆服务器,那么这篇文章就结束了
|
||||
|
||||
## 反向代理加速
|
||||
众所周知,cloudflare在中国大陆的访问速度极慢,所以可以使用自己的服务器套一层加速
|
||||
我这里使用一台香港CN2GIA线路的服务器和nginx做演示
|
||||
(或许你可以去导航栏的推广页看看,那里获取会有这种服务器,如果那个页面在你看到的时候还在)
|
||||
```nginx
|
||||
location ^~ / {
|
||||
proxy_pass https://xxx.xxx.workers.dev;
|
||||
proxy_set_header Host xxx.xxx.workers.dev;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header REMOTE-HOST $remote_addr;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_http_version 1.1;
|
||||
add_header X-Cache $upstream_cache_status;
|
||||
add_header Strict-Transport-Security "max-age=31536000";
|
||||
add_header Cache-Control no-cache;
|
||||
}
|
||||
```
|
||||
使用面板创建的反向代理是这样的,但是你会发现这是访问显示502
|
||||
这是因为Nginx在建立SSL/TLS连接时没有发送服务名到后端服务器,导致导致后端服务器使用错误的证书或拒绝连接,所以需要做以下修改:
|
||||
```nginx
|
||||
location ^~ / {
|
||||
proxy_pass https://xxx.xxx.workers.dev;
|
||||
proxy_set_header Host xxx.xxx.workers.dev;
|
||||
proxy_set_header X-Real-IP $remote_addr;
|
||||
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
|
||||
proxy_set_header REMOTE-HOST $remote_addr;
|
||||
proxy_set_header Upgrade $http_upgrade;
|
||||
proxy_set_header Connection "upgrade";
|
||||
proxy_set_header X-Forwarded-Proto $scheme;
|
||||
proxy_http_version 1.1;
|
||||
proxy_ssl_server_name on; # 使Nginx在建立SSL/TLS连接时发送服务名到后端服务器
|
||||
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # 指定Nginx应该使用的SSL/TLS协议版本
|
||||
add_header X-Cache $upstream_cache_status;
|
||||
add_header Strict-Transport-Security "max-age=31536000";
|
||||
add_header Cache-Control no-cache;
|
||||
}
|
||||
```
|
||||
|
||||
添加了以下两行配置
|
||||
|
||||
```
|
||||
proxy_ssl_server_name on; # 使Nginx在建立SSL/TLS连接时发送服务名到后端服务器
|
||||
proxy_ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # 指定Nginx应该使用的SSL/TLS协议版本
|
||||
```
|
||||
访问`://YOURHOSTNAME/v1/chat/completions`
|
||||
若出现以下回复就配置成功了
|
||||
```json
|
||||
{
|
||||
"error": {
|
||||
"message": "You didn't provide an API key. You need to provide your API key in an Authorization header using Bearer auth (i.e. Authorization: Bearer YOUR_KEY), or as the password field (with blank username) if you're accessing the API from your browser and are prompted for a username and password. You can obtain an API key from https://platform.openai.com/account/api-keys.",
|
||||
"type": "invalid_request_error",
|
||||
"param": null,
|
||||
"code": null
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### 参考文章
|
||||
[最新宝塔反代openai官方API开发接口详细搭建教程,解决502 Bad Gateway问题](https://blog.csdn.net/weixin_43227851/article/details/134404942)
|
||||
[ChatGPT-Proxy](https://gitee.com/GoGPTAI/ChatGPT-Proxy)
|
||||
Reference in New Issue
Block a user