NOTE

1.3 文件服务器

使用 Nginx autoindex 搭建简单文件服务器。

Web Server / Nginx创建于 更新于 约 1 分钟读完historical

这是历史学习笔记,可能存在过时或不完整的理解。

1. 配置

  • /etc/nginx/nginx.conf
http {
    #...
    include /etc/nginx/conf.d/*.conf;
    #...
}
  • /etc/nginx/conf.d/cdn.conf
autoindex on;             #开启索引功能
autoindex_exact_size off; # 关闭计算文件确切大小(单位bytes),只显示大概大小(单位kb、mb、gb)
autoindex_localtime on;   # 显示本机时间而非 GMT 时间
charset utf-8; # 避免中文乱码

server {
	listen       9999; #监听端口号
	# server_name  localhost;
	#root         /usr/share/nginx/html;
	root         <USER_HOME>/share; # 共享的文件目录
	error_log <USER_HOME>/share/log/error.log ; # 报错的文件目录

	location / {
	}

	error_page 404 /404.html;
	location = /40x.html {
	}

	error_page 500 502 503 504 /50x.html;
	location = /50x.html {
	}
}

2. 参考

讨论

使用 GitHub 账号参与讨论,评论会保存在 GitHub Issues 中。在 GitHub 查看