Hexo -33- 私有服务器通过 nginx 建立图床

本文最后更新于:2022年7月4日 上午

经过各种图床折腾之后,发现可以在自己的服务器中直接建立 nginx 站点作为专门的图床使用,本文记录相关内容。

背景

  • 在折腾 chevereto 自建图床的过程中,发现核心功能可以剥离出来直接用 nginx 维护实现

建立站点

宝塔

  • 在宝塔面板配置需要安装宝塔面板,并配置 Nginx 环境
  • 建立站点

Nginx 服务器

  • 直接配置 Nginx 文件
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
worker_processes auto;
pid /run/nginx.pid;

events {
worker_connections 768;
# multi_accept on;
}

http {

sendfile on;
tcp_nopush on;
tcp_nodelay on;
keepalive_timeout 65;
types_hash_max_size 2048;
include /etc/nginx/mime.types;
default_type application/octet-stream;

ssl_protocols TLSv1 TLSv1.1 TLSv1.2; # Dropping SSLv3, ref: POODLE
ssl_prefer_server_ciphers on;

access_log /var/log/nginx/access.log;
error_log /var/log/nginx/error.log;

gzip on;
gzip_disable "msie6";

server{
listen 80;
server_name localhost;
location /{
root /;
# autoindex on;
}
}
include /etc/nginx/conf.d/*.conf;
#include /etc/nginx/sites-enabled/*;
}
  • 重启 nginx
1
sudo nginx -s reload

读取图床数据

  • 在网站根目录存放的数据已经可以直接访问了,链接规则
1
web-url / file-path
  • 在站点根目录存入图像 1.png

  • 直接访问 web-url / 1.png即可直接看到图像内容

  • 软链接文件也是可以读取的

参考资料



文章链接:
https://www.zywvvd.com/notes/hexo/website/33-nginx-imgbed/nginx-imgbed/


Hexo -33- 私有服务器通过 nginx 建立图床
https://www.zywvvd.com/notes/hexo/website/33-nginx-imgbed/nginx-imgbed/
作者
Yiwei Zhang
发布于
2022年5月20日
许可协议