使用条件:
- 机器位于大陆之外
- 能修改伪静态
- 有一个理智的大脑和灵活的双手
- 原神冒险等级>=50
👩💻第一步 安装 FoF Upload
之后修改FoF Upload的配置
自己找一下如何申请imgurID教程 申请之后填进去就可以
🔮第二步 利用重写来代理imgur
打开你的伪静态文件
将以下内容 插入到 location / {
后面
如果你没有特殊需要你就不需要改了
那么你的图片代理地址就是
location ~ ^/im-file/.+\.(png|jpg|jpeg|gif|gifv)$ {
rewrite ^/im-file(/.*)$ $1 break;
proxy_pass https://i.imgur.com;
proxy_buffering off;
proxy_set_header Referer "";
proxy_set_header User-Agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";
#proxy_cache STATIC;
#proxy_cache_key $uri;
#proxy_cache_valid 200 30d;
#proxy_cache_use_stale error timeout invalid_header updating
# http_500 http_502 http_503 http_504;
#add_header X-Nginx-Cache $upstream_cache_status;
}
location /file-api/ {
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
rewrite ^/file-api/(.*)$ /$1 break;
proxy_pass https://api.imgur.com;
proxy_buffering off;
proxy_set_header Referer "";
proxy_set_header User-Agent "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36";
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header Upgrade "websocket";
proxy_set_header Connection "Upgrade";
}
😨最后一步修改FoF Upload源码
注意本操作有风险,请自行备份源码,防止你自己改坏了
来到网站根目录 找到如下文件
/vendor/fof/upload/src/Adapters/
如果你有编辑器就搜 successful upload, let's get the generated URL
然后将 if语句替换为我下面的部分,然后把 https://www.pibopibo.com/im-file/ 换成你自己的
// successful upload, let's get the generated URL
if ($response->getStatusCode() == 200) {
$meta = Arr::get(json_decode($response->getBody(), true), 'data', []);
$link = Arr::get($meta, 'link');
# $file->url = $link;
// Replace the link with the desired proxy link
$proxyLink = str_replace('https://i.imgur.com/', 'https://www.pibopibo.com/im-file/', $link);
$file->url = $proxyLink;
$file->remote_id = Arr::get($meta, 'id');
}
刷新缓存
php flarum cache:clear
刷新后上传出现链接 打开后是图片 就是你代理成功了