配置

nginx 启动
nginx -t 查看配置
nginx -s reload 重启
nginx -s stop 关闭
nginx -V 查看模块

  • 禁止缓存
    location ~* \.(js|css|png|jpg|gif|webp)$ {
      add_header Cache-Control no-store;
    }
  • 防盗链
    location ~* \.(gif|jpg|png)$ {
      valid_referers none blocked 192.168.0.1;
      if ($invalid_referer) {
         rewrite ^/ http://$host/logo.png;
      }
    }
  • 显示目录
    autoindex on;
    autoindex_exact_size off;
    autoindex_localtime on;

    openssl生成密码

sh -c "echo -n 'admin:' >> pwd"
sh -c "openssl passwd -apr1 >> pwd"
123456 生成内容  admin:$apr1$.SYLFc6u$uCNTvsdcaBzD/8ikf/TVe.

auth_basic "Restricted Content";
auth_basic_user_file C:/app/caddy/nginx/pwd;
}
文档更新时间: 2024-09-12 14:27   作者:Yoby