设置自动目录
location / {
autoindex on;
}
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 |
设置访问密码
auth_basic "Please input password";
auth_basic_user_file /root/password;
拒绝指定的 IP 访问
allow 127.0.0.1; # 只允许来自本机的访问
deny all; # 拒绝所有访问
你也可以设置拒绝特定 IP 段的访问.
解决 POST 时出现的 405 错误
server {
listen 80;
server_name localhost;
location / {
root html;
index index.html index.htm;
}
error_page 404 /404.html;
error_page 403 /403.html;
# To allow POST on static pages 允许静态页使用POST方法
error_page 405 =200 $uri;
}
PS: Nginx 如果要上传文件, 需要编译 Nginx. apt install nginx 所安装的 Nginx 需要卸载, 方法暂略.