gohttpserver私有图床

gitee关闭了公开服务,即使是公开仓库只有登录用户才能看到,而一旦检测到图床则被强制设置为私有仓库,以致于之前上传的图片全部不能显示

只有自己的图床靠谱,使用gohttpserver服务:https://github.com/codeskyblue/gohttpserver

其通过API上传的curl命令为

curl -X DELETE http://go.d5.sensetime.com/sunye/visualize/all.tar.gz
curl -F file=@all.tar.gz http://go.d5.sensetime.com/sunye/visualize

# 例如
(jupyter) root@sunye:/Server/background/act# curl -F file=@0.jpg https://n.ye-sun.com:9000/gallery/2022summer
{"destination":"/app/public/gallery/2022summer/0.jpg","success":true}

使用到了**picgo-plugin-web-uploader**插件,按照上述参数设置picgo

image-20220605213008213

发现确实上传到gohttpserver了,但是其返回值却不是路径名,而是json格式的返回值: {"destination":"/app/public/202206052131728.png","success":true}

因此进一步开发picgo自定义Web图床插件(picgo-plugin-web-uploader-re)用于更复杂的正则替换:

新增了两个配置项 matchPattern 和 replacePattern,用于接收正则表达式的匹配模式和替换模式。在处理函数中,对解析出的 imgUrl 进行正则替换:imgUrl.replace(new RegExp(matchPattern, 'g'), replacePattern)

示例1:将 /images/uploaded/pic.jpg 替换为 https://cdn.example.com/pic.jpg:

示例2:将任意文件路径 pic.jpg、images/test.png 等替换为带前缀的 URL,例如 https://cdn.example.com/pic.jpg、https://cdn.example.com/images/test.png:

image-20240602184542958

image-20240602184615150

gohttpserver README美化

see yue主题是一个一个自定义样式极多、简约、充满细节的 Typora 明亮主题,相当美观

image-20220607122556062

是否可以在渲染readme时加载see-yue主题

只要将主题替换一下即可:

image-20220607122913533

具体方案:

git clone https://gitee.com/sun__ye/gohttpserver
cd gohttpserver/assets
docker cp index.html `docker inspect -f '{{.ID}}' go`:/app/assets/index.html

获取证书

简介:https://segmentfault.com/a/1190000018764083

安装证书:https://www.frankfeekr.cn/2021/03/28/let-is-encrypt-cerbot-for-https/

非标准端口使用证书:https://segmentfault.com/a/1190000040908221

apt install -y python3-certbot-nginx

certbot certonly --preferred-challenges dns --manual -d *.sunie.top --server https://acme-v02.api.letsencrypt.org/directory

# 输出
IMPORTANT NOTES:
 - Congratulations! Your certificate and chain have been saved at:
   /etc/letsencrypt/live/sunie.top/fullchain.pem
   Your key file has been saved at:
   /etc/letsencrypt/live/sunie.top/privkey.pem
   Your cert will expire on 2022-09-05. To obtain a new or tweaked
   version of this certificate in the future, simply run certbot
   again. To non-interactively renew *all* of your certificates, run
   "certbot renew"
 - If you like Certbot, please consider supporting our work by:

   Donating to ISRG / Let's Encrypt:   https://letsencrypt.org/donate
   Donating to EFF:                    https://eff.org/donate-le

nginx配置如下:

# 443 https 配置
server {
    listen 9000 ssl http2;
    server_name  n.ye-sun.com;

    ssl                      on;
    ssl_certificate          /etc/letsencrypt/live/sunie.top/fullchain.pem;
    ssl_certificate_key      /etc/letsencrypt/live/sunie.top/privkey.pem;

    ssl_session_timeout  5m;

    ssl_ciphers HIGH:!aNULL:!MD5;
    ssl_protocols SSLv3 TLSv1 TLSv1.1 TLSv1.2;
    ssl_prefer_server_ciphers   on;

    location / {
        proxy_pass http://127.0.0.1:9051;
    }
}

image-20220607173115219

成功通过https访问,但是仍然显示不安全?

  • 原因?

使用http上传,但是使用https访问: