关闭站点评论功能 (防垃圾机器人评论) 

我这个小博客一直有垃圾评论我是知道的,只不过这两天越来越多。几百上千条。。。。

验证码功能可能是废的。

以前不去弄它是因为反正我也不看,我一般就是记录完一个事情就直接关了,也没感觉到垃圾评论有多烦人。

今天顺手弄了下Google Webmaster,接到了一个关于站点被注入的警告。如图:


才开始重视起来。

问题来了:
我这个小博客数据持久华没有使用任何关系型数据库....是存储在纯文本里面的。因此我不可能简简单单的用几条sql 就 delete 掉那些垃圾数据。

而且坑爹的是,这个小博客的后台还没有提供评论管理这样的一个聚合模块,我的一个一个的文章点进去,一个一个评论删除。没有全选之类的。

研究了一下网站文件目录,发现它的每条评论都是以“commentYY-MMDD-xxxx.txt” 这样的格式存放的。

我看了一下,大部分的垃圾评论都是17,18,19年这几年产生的,所以我就一刀切的把这段时间的评论文件都给删除了,无论内容好坏。


[root@forever-free linux_xiazhengxin_name]# find . -name "comment19*.txt"
./content/12/04/entry120406-221549/comments/comment190123-064343.txt
./content/12/04/entry120416-191734/comments/comment190118-175419.txt
./content/12/04/entry120416-191734/comments/comment190118-204718.txt
./content/12/04/entry120416-191734/comments/comment190119-132050.txt
./content/12/04/entry120416-191734/comments/comment190119-195101.txt
./content/12/04/entry120416-191734/comments/comment190119-233843.txt
./content/12/04/entry120416-191734/comments/comment190120-032256.txt
./content/12/04/entry120416-191734/comments/comment190120-035428.txt
./content/12/04/entry120416-191734/comments/comment190120-234336.txt
./content/12/04/entry120416-191734/comments/comment190121-113012.txt
.........
./content/09/07/entry090724-203404/comments/comment190131-050547.txt
./content/09/07/entry090724-203404/comments/comment190131-084334.txt
./content/09/09/entry090905-014037/comments/comment190123-064519.txt
./content/09/09/entry090905-014037/comments/comment190123-064647.txt
[root@forever-free linux_xiazhengxin_name]# find . -name "comment19*.txt" -exec rm -f {} \;


删完之后,感觉世界都清净了。

此外,考虑到这个提交评论的验证码应该是个摆设,而我也没心思去换一个验证机制,再加上博客也没啥人气,就干脆把评论功能关了。省事!!!
[ ] ( 1287 次浏览 ) 永久链接 ( 3 / 1490 )
给512MB RAM GCP 美区实例添加交换空间 

最近博客经常提示 db error,mariadb 总是莫名其妙的shutdown.查看error.log 发现是 out of memory.

说实话这512MB的VPS我实在不知道该怎么优化,只好寄希望于加个swap space 来顶一顶。好在机器的硬盘还算大。打算分配个1GB出来。

首先在本地创建一个1GB大小的swapfile.

dd if=/dev/zero of=/swapfile bs=1G count=1

别用下面这个命令,会出错。因为它是快速划分空间,并不会即时占用原始大小的空间。

fallocate -l 1G /swapfile //会出错

接下来:

chmod 600 /swapfile //更改权限为 600.

mkswap /swapfile //创建交换格式文件

swapon /swapfile //启用交换文件

接下来可以用过 free -h 或者 htop 或者 swapon -s 看到 swap 已经生效了。

如果你嫌每次都要手动挂载swap 麻烦,可以把配置写入fstab,让其开机自动挂载。
编辑 /etc/fstab 文件,载入一行

/swapfile swap swap rw 0 0


保存即可。重启下可以看到已经生效了。

注:我的系统是CentOS 7.

本文撰写时候参考了以下文章:
https://aws.amazon.com/cn/premiumsupport/knowledge-center/ec2-memory-swap-file/
https://www.digitalocean.com/community/tutorials/how-to-add-swap-on-centos-7
[ ] ( 975 次浏览 ) 永久链接 ( 3 / 1263 )
thttpd http server 内存使用量太大的疑问 

前段时间搞了个腾讯云的7天体验服务器,难得国内的机房没备案的域名也能解析。就折腾了一下。

搞了一个号称最迷你的httpd server - thttpd.

官网:https://acme.com/software/thttpd/

下载最新的版本源码:
https://acme.com/software/thttpd/thttpd-2.28.tar.gz

解压,编译,安装。

复制 源码包内的配置文件,稍加修改,运行。

一看进程表,吓我一跳,咋thttpd 一个进程就占掉了我VPS 19%的内存!!!






ubuntu@powerpc:~$ free -m
total used free shared buff/cache available
Mem: 857 315 368 24 173 364
Swap: 0 0 0
ubuntu@powerpc:~$ ps aux | grep http
root 8320 0.0 3.2 251016 28484 ? Sl Mar07 0:01 php http.php
root 8321 0.0 0.6 176788 5644 ? S Mar07 0:00 php http.php
root 8323 0.0 1.2 179084 10652 ? S Mar07 0:00 php http.php
root 12666 0.0 5.0 669132 44024 ? Ssl Mar06 1:55 jexus: httpd worker jwsHttpd.exe
www-data 23634 0.2 18.8 191308 165948 ? Ss 15:51 0:06 /opt/thttpd/sbin/thttpd -C /opt/thttpd/config/thttpd.conf
ubuntu 26157 0.0 0.1 13232 1088 pts/0 S+ 16:34 0:00 grep --color=auto http
ubuntu@powerpc:~$


我tmd 当场就惊呆了,这内存占用快赶上MySQL了。

于是,在它的网站上找找,看有没有关于内存使用的相关配置字段,很遗憾没找到。而且由于它的功能定位很简单,导致了配置文件的选项也很少。目测不超过15个。
这是我的配置:

ubuntu@powerpc:~$ cat /opt/thttpd/config/thttpd.conf
# This section overrides defaults
port=80
dir=/var/www/html
nochroot
#data_dir
nosymlinkcheck
novhost
noglobalpasswd
user=www-data
host=0.0.0.0
logfile=/var/log/thttpd.log
pidfile=/var/run/thttpd.pid
charset=gbk
max_age=60


应该没啥毛病啊~

在它的首页我看到这样一句话:

Small:
See the comparison chart. It also has a very small run-time size, since it does not fork and is very careful about memory allocation.


意思就是:“我很小,我不会无聊的复制我自己,而且在内存分配方面我很谨慎”

这……我该如何理解这句话。

1.它不像nginx、php-fpm 那样会派生出很多worker,按说内存使用总量应该不会太大。
2.如果它没有派生功能,一直都是单进程。那么好像初始运行内存开辟大点,好像也没问题。

实在是看不懂。

后来我没辙,只能看看网友有没有和我一样有这样的疑惑,结果找到了一封18年前的邮件列表记录:

https://marc.info/?l=thttpd&m=102182637422558&w=2

面对用户关于“thttpd memory usage?”的疑问,acme的成员解释道:你用的内存查看工具是有问题的,是不准确的!

如下:

On some OSs, top seems to count memory-mapped files as part of the
program size. That makes thttpd look much bigger than it really is.


666~在下服了。
[ ] ( 3578 次浏览 ) 永久链接 ( 3 / 1811 )
呵呵,呵呵,呵呵呵 

接上一文。

刚刚抱着试试看的心态,以“digitalocean https 不通”为关键词百度了一下,发现了一个帖子。

https://www.v2ex.com/t/412798

看完我就大概明白了。还TMD一直以为自己配置哪里出了问题,卧槽,呵呵。

注:还搜到了一篇讲lighttpd 部署SSL证书的教程,来自某SSL证书销售商官网。666 不过写的蛮好的,可以用来参考。

https://doc.ssl.do/page/install-lighttpd/

因为和nginx 比起来,lighttpd 实在太小众了,中文文档确实少的可怜。
[ ] ( 1792 次浏览 ) 永久链接 ( 3.1 / 1730 )
lighttpd https SSL 配置参数优化 

前端时间从 freessl.org 搞了一个免费的SSL证书,给自己的一个站点用上了。

https://sb.caonima.pw

不过部署好了后我这边一直访问不了。一直以为是SSL的配置没配好。

今天参照着 myssl.com 提供的优化建议把配置弄了一下,如下:

$SERVER["socket"] == ":443" {
ssl.engine = "enable"
ssl.use-sslv2 = "disable"
ssl.use-sslv3 = "disable"
#ssl.openssl.ssl-conf-cmd = ("Protocol" => "-ALL, TLSv1.2")
ssl.cipher-list = "ECDHE-RSA-AES128-GCM-SHA256:ECDHE:ECDH:AES:HIGH:!NULL:!aNULL:!MD5:!ADH:!RC4:!DH:!DHE"
ssl.honor-cipher-order = "enable"
ssl.pemfile = "/home/ftp/.ssl/ssl.pem"
ssl.ca-file = "/home/ftp/.ssl/ca.pem"
server.name = "sb.caonima.pw"
server.document-root = "/home/ftp"
}
ssl.disable-client-renegotiation = "enable"


重启lighttpd,看了一下,评级从之前的B升到了A。

https://myssl.com/sb.caonima.pw

但是,貌似我本地还是不能访问。

VPS里面倒是可以,

[root@sharl-centos ~]# curl -vI https://sb.caonima.pw
* About to connect() to sb.caonima.pw port 443 (#0)
* Trying 104.236.147.24... connected
* Connected to sb.caonima.pw (104.236.147.24) port 443 (#0)
* Initializing NSS with certpath: sql:/etc/pki/nssdb
* CAfile: /etc/pki/tls/certs/ca-bundle.crt
CApath: none
* SSL connection using TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256
* Server certificate:
* subject: CN=sb.caonima.pw
* start date: Feb 24 00:00:00 2018 GMT
* expire date: Feb 24 12:00:00 2019 GMT
* common name: sb.caonima.pw
* issuer: CN=TrustAsia TLS RSA CA,OU=Domain Validated SSL,O="TrustAsia Technologies, Inc.",C=CN
> HEAD / HTTP/1.1
> User-Agent: curl/7.19.7 (x86_64-redhat-linux-gnu) libcurl/7.19.7 NSS/3.27.1 zlib/1.2.3 libidn/1.18 libssh2/1.4.2
> Host: sb.caonima.pw
> Accept: */*
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
< Content-Type: text/html; charset=UTF-8
Content-Type: text/html; charset=UTF-8
< Content-Length: 6705
Content-Length: 6705
< Date: Fri, 02 Mar 2018 09:10:51 GMT
Date: Fri, 02 Mar 2018 09:10:51 GMT
< Server: lighttpd
Server: lighttpd

<
* Connection #0 to host sb.caonima.pw left intact
* Closing connection #0


此外我还试了ssllibs,
https://www.ssllabs.com/ssltest/analyze.html?d=sb.caonima.pw

好像也没啥问题。敢情除了我自己,其他人都能访问我的站点,我日!!!!

这个问题还要继续研究。

注:本文撰写实践参考了以下链接:
https://redmine.lighttpd.net/projects/lighttpd/wiki/Docs_SSL
https://www.openssl.org/docs/manmaster/man1/ciphers.html
[ ] ( 4037 次浏览 ) 永久链接 ( 3 / 1709 )

<< <上一页 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 下一页> >>