设置自动目录

  1. location / {
  2. autoindex on;
  3. }
Syntax: **autoindex**on` off;`
Default: autoindex off;
Context: http, server, location
Syntax: **autoindex_exact_size**on` off;`
Default: autoindex_exact_size on;
Context: http, server, location
Syntax: **autoindex_localtime**on` off;`
Default: autoindex_localtime off;
Context: http, server, location

设置访问密码

  1. auth_basic "Please input password";
  2. auth_basic_user_file /root/password;

拒绝指定的 IP 访问

  1. allow 127.0.0.1; # 只允许来自本机的访问
  2. deny all; # 拒绝所有访问

你也可以设置拒绝特定 IP 段的访问.

解决 POST 时出现的 405 错误

  1. server {
  2. listen 80;
  3. server_name localhost;
  4. location / {
  5. root html;
  6. index index.html index.htm;
  7. }
  8. error_page 404 /404.html;
  9. error_page 403 /403.html;
  10. # To allow POST on static pages 允许静态页使用POST方法
  11. error_page 405 =200 $uri;
  12. }

PS: Nginx 如果要上传文件, 需要编译 Nginx. apt install nginx 所安装的 Nginx 需要卸载, 方法暂略.