分类 默认分类 下的文章

清理数据库中的统计信息和检测日志
注意:该操作会清除所有日志信息,且不可恢复

docker exec safeline-mgt cleanlogs

雷池占用磁盘,如何清理空间(清理统计数据)
大流量情况下,统计数据比较占用存储空间,如果发现luigi文件空间占用过大

有些环境需要使用docker-compose的命令,自行替换即可:

  • 停止雷池,在安装的safeline目录下执行命令:docker compose down
  • 直接删除 safeline/resources/luigi 文件夹
  • 启动雷池,在安装的safeline目录下执行命令:docker compose up -d
  • 删除文件会丢失统计数据,注意数据备份

其它常见问题及故障排查处理请参考官方文档:
https://docs.waf-ce.chaitin.cn/zh/%E5%B8%B8%E8%A7%81%E9%97%AE%E9%A2%98%E6%8E%92%E6%9F%A5

iopaint是一个开源的AI去水印的工具,可以本地部署

Install pytorch
If you want to run model on GPU, it is necessary to install the GPU version of PyTorch. Otherwise, you can skip this step.

For NVIDIA GPU users

pip3 install torch==2.1.2 torchvision==0.16.2 --index-url https://download.pytorch.org/whl/cu118

For AMD GPU users, only works on linux, as pytorch is not yet supported on Windows with ROCm.

pip3 install torch==2.1.2 torchvision==0.16.2 --index-url https://download.pytorch.org/whl/rocm5.6

Install IOPaint
pip3 install iopaint

**Start IOPaint server**

iopaint start --model=lama --device=cpu --port=8080

IOPaint is now running at http://localhost:8080(opens in a new tab), you can open it in your browser to start using it.

You can see all command line arguments using iopaint start --help, and you can see more models and features in the models page.


**解决安装Failed building wheel for pillow**
解决error: command ‘x86_64-linux-gnu-gcc‘ failed with exit status 1

apt-get install libjpeg-dev zlib1g-dev

查看自己python的版本,然后下载自己版本Python的devel,比如python3.7.7就是

sudo apt-get install python3.7-dev

sudo apt-get install build-essential python3-dev libssl-dev libffi-dev libxml2 libxml2-dev libxslt1-dev zlib1g-dev

对于做国内网站来说,我不希望国外蜘蛛来访问我的网站,这些垃圾流量多了之后,严重浪费服务器的带宽和资源。通过判断user agent,在nginx中禁用这些蜘蛛可以节省一些流量,也可以防止一些恶意的访问。

解决方案
修改nginx.conf,禁止网络爬虫的user_agent,返回403。

1、 进入nginx的配置目录,例如cd /usr/local/nginx/conf
2、添加agent_deny.conf配置文件 vim agent_deny.conf

#禁止Scrapy等爬虫工具的抓取 Baiduspider
if ($http_user_agent ~* "Scrapy|Sogou web spider") {
  return 403;
}

#禁止指定UA及UA为空的访问
if ($http_user_agent ~ "Scrapy|SemrushBot|FeedDemon|JikeSpider|Indy Library|Alexa Toolbar|AskTbFXTV|AhrefsBot|CrawlDaddy|CoolpadWebkit|Java|Feedly|UniversalFeedParser|ApacheBench|Microsoft URL Control|Swiftbot|ZmEu|oBot|jaunty|Python-urllib|lightDeckReports Bot|YYSpider|DigExt|YisouSpider|HttpClient|MJ12bot|heritrix|EasouSpider|LinkpadBot|Ezooms|^$" )
{
  return 403;
}
#禁止非GET|HEAD|POST方式的抓取
if ($request_method !~ ^(GET|HEAD|POST)$) {
  return 403;
}

#添加针对特殊的user_agent的访问

if ($http_user_agent ~ "Mozilla/4.0\ \(compatible;\ MSIE\ 6.0;\ Windows\ NT\ 5.1;\ SV1;\ .NET\ CLR\ 1.1.4322;\ .NET\ CLR\ 2.0.50727\)") { 
   return 404;
}

在server层的网站配置中include这个配置文件进来,nginx -t 测试配置格式是否通过,再重启nginx服务

然后测试一下
用curl命令模拟浏览器头信息, 设置是否成功,curl的-A 可以让我们随意指定自己这次访问所宣称的自己的浏览器信息

#curl -I -A “BaiduSpider” www.test.com

HTTP/1.1 200 OK
Server: nginx
Date: Mon, 09 Feb 2022 09:37:20 GMT
Content-Type: text/html; charset=UTF-8 Connection: keep-alive
Vary: Accept-Encoding
X-Powered-By: PHP/5.5.19 Vary: Accept-Encoding, Cookie
Cache-Control: max-age=3, must-revalidate
WP-Super-Cache: Served supercache file from PHP

#curl -I -A “JikeSpider” www.test.com

HTTP/1.1 403 Forbidden
Server: nginx Date: Mon, 09 Feb 2022 09:37:44 GMT
Content-Type: text/html
Content-Length: 162 Connection: keep-alive

nginx通过判断User-Agent屏蔽蜘蛛访问网站就已经完成,可以根据实际情况对agent_deny.conf中的蜘蛛进行增加、删除或者修改。

2、网站根目录下增加Robots.txt,放在站点根目录下。
http://tool.chinaz.com/robots/站点可以针对现在的搜索引擎按照想要的规则生成robots.txt文件。

https://stackoverflow.com/questions/47374678/how-to-detect-ecmascript-version

var ecmaScriptInfo = (function() {
                  // () => { is not allowed
  function getESEdition() {
    var array = [];
    switch (true) {
      case !Array.isArray:
        return 3;
      case !window.Promise:
        return 5;
      case !array.includes:
        return 6;
      case !''.padStart:
        return 7;
      case !Promise.prototype.finally:
        return 8;
      case !window.BigInt:
        return 9;
      case !Promise.allSettled:
        return 10;
      case !''.replaceAll:
        return 11;
      case !array.at:
        return 12;
      default:
        return 13;
    }
  }

  function getESYear(edition) {
    return {
      3: 1999,
      5: 2009
    }[edition] || (2009 + edition); // nullish coalescing (??) is not allowed
  }
  
  var edition = getESEdition();
  var year = getESYear(edition);

  return {
    edition: edition, // usually shortened [edition,]
    year: year,       // usually shortened [year,]
    text: 'Edition: '+ edition +' | Year: '+ year
       // `Edition: ${edition} | Year: ${year}` is not allowed
  }
})();

console.log(ecmaScriptInfo.edition);
console.log(ecmaScriptInfo.year);
console.log(ecmaScriptInfo.text);