让网维变得简单,快速,准确。拒绝浪费时间,解放出更多的时间陪陪家人。 注册 | 登陆
浏览模式: 标准 | 列表Tag:nginx

nginx限速及连接数限制

在nginx.conf的http{}添加
limit_zone one $binary_remote_addr 10m;

然后在 虚拟机里写
location / {
limit_conn one 1; 线程
limit_rate 100k; 速度
表示限速100K 每个客户端只允许一个线程

最终速度=rate * conn

-----------------------------------------------------------------

limit_zone one $binary_remote_addr 32k;
server {
listen       80;
server_name  192.168.1.222;
location / {
root   /var/www/html;
index  index.html index.htm index.php;
autoindex on;
autoindex_exact_size off;
autoindex_localtime on;
limit_conn one 2;
limit_rate 10k;
}


说明:

limit_zone,针对每个IP定义一个存储session状态的容器。要求大于等于32K。

limit_conn,限制每个IP发起的连接数,比如本实例设了2个,当我用IE进行单线程下载的时候还可以打开该站点的一个网页。而用迅雷下载时,迅雷会启用2个线程下载,所以当再去打开网页的时候,服务器端会返回错误请求。该值建议设置得高一些,比如15左右。

limit_rate,限制每个连接速度为10K,此限制是针对单个线程,比如这个例子,我用IE下载是10K,当用迅雷时它会占用2个线程,所以迅雷下载速度为20K,此实例也很好的解释了迅雷下载速度快的原因。

» 阅读全文

Tags: nginx, 限速, 连接数, 限制, 并发

本站已经将LNMP改为了LAMP了

       已经于今日WEB平台迁移完毕,由于一开始忘了备份数据库,反复折腾,这个VPS速度又不快的原因,搞了好久,最后总算是搞好了,汗死我了。还好这个VPS有备份功能,可以快速恢复,不然被折腾到死。
       现在的LAMP虽然没有LNMP速度快,但是其实也差不了多少,几乎感觉不到。但是安全性高多了,虚拟主机共存权限隔离的问题也解决了,安心了。

» 阅读全文

Tags: web, 服务器, apache, nginx

nginx服务管理

但研究了一下nginx帮助后发现,有-s参数可对nginx服务进行管理:
# /usr/local/nginx/sbin/nginx -h
nginx version: nginx/0.7.63
Usage: nginx [-?hvVt] [-s signal] [-c filename] [-p prefix] [-g directives]

Options:
-?,-h : this help
-v : show version and exit
-V : show version and configure options then exit
-t : test configuration and exit
-s signal : send signal to a master process: stop, quit, reopen, reload
-p prefix : set prefix path (default: /usr/local/nginx/)
-c filename : set configuration file (default: conf/nginx.conf)
-g directives : set global directives out of configuration file

于是我执行
# /usr/local/nginx/sbin/nginx -s  reload
nginx已经重启成功

» 阅读全文

Tags: nginx, 参数, 命令, 服务, 管理