VPS侦探论坛

标题: nginx无法实现模块限制速度并发数 [打印本页]

作者: longyushen    时间: 2012-11-2 12:49
标题: nginx无法实现模块限制速度并发数
nginx无法实现模块限制速度并发数
出现如下错误
  1. nginx: [emerg] unknown directive "log_format" in /usr/local/nginx/conf/nginx.conf:62
复制代码
nginx配置如下
  1. user  www www;worker_processes 1;error_log  /home/wwwlogs/nginx_error.log  crit;pid        /usr/local/nginx/logs/nginx.pid;#Specifies the value for maximum file descriptors that can be opened by this process.
  2. worker_rlimit_nofile 51200;events
  3. {
  4.   use epoll;
  5.   worker_connections 51200;
  6. }http
  7. {
  8.   include       mime.types;
  9.   default_type  application/octet-stream;  server_names_hash_bucket_size 128;
  10.   client_header_buffer_size 32k;
  11.   large_client_header_buffers 4 32k;
  12.   client_max_body_size 50m;  sendfile on;
  13.   tcp_nopush     on;  keepalive_timeout 60;  tcp_nodelay on;  fastcgi_connect_timeout 300;
  14.   fastcgi_send_timeout 300;
  15.   fastcgi_read_timeout 300;
  16.   fastcgi_buffer_size 64k;
  17.   fastcgi_buffers 4 64k;
  18.   fastcgi_busy_buffers_size 128k;
  19.   fastcgi_temp_file_write_size 256k;  gzip on;
  20.   gzip_min_length  1k;
  21.   gzip_buffers     4 16k;
  22.   gzip_http_version 1.0;
  23.   gzip_comp_level 2;
  24.   gzip_types       text/plain application/x-javascript text/css application/xml;
  25.   gzip_vary on;  # limit_zone   one  $binary_remote_addr  10m;  
  26.   server {
  27.     location /www/ {
  28.       limit_conn   one  2;
  29.       limit_rate 300k;
  30.     }
  31.   }
  32. }   #log format
  33.   log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  34.              '$status $body_bytes_sent "$http_referer" '
  35.              '"$http_user_agent" $http_x_forwarded_for';include vhost/*.conf;
  36. }  
复制代码

作者: skyfree    时间: 2012-11-3 07:53
# limit_zone   one  $binary_remote_addr  10m;

把#去掉好吧……?
作者: licess    时间: 2012-11-3 16:53
我只能说配置文件已经让你该的面目全非了

只按错误提示log_format放错地方了,要在server前面
作者: longyushen    时间: 2012-11-5 09:24
原帖由 licess 于 2012-11-3 16:53 发表
我只能说配置文件已经让你该的面目全非了

只按错误提示log_format放错地方了,要在server前面

对于下面的源码,该怎么写呢?

  1. user  www www;worker_processes 1;error_log  /home/wwwlogs/nginx_error.log  crit;pid        /usr/local/nginx/logs/nginx.pid;#Specifies the value for maximum file descriptors that can be opened by this process.
  2. worker_rlimit_nofile 51200;events
  3. {
  4.   use epoll;
  5.   worker_connections 51200;
  6. }http
  7. {
  8.   include       mime.types;
  9.   default_type  application/octet-stream;  server_names_hash_bucket_size 128;
  10.   client_header_buffer_size 32k;
  11.   large_client_header_buffers 4 32k;
  12.   client_max_body_size 50m;  sendfile on;
  13.   tcp_nopush     on;  keepalive_timeout 60;  tcp_nodelay on;  fastcgi_connect_timeout 300;
  14.   fastcgi_send_timeout 300;
  15.   fastcgi_read_timeout 300;
  16.   fastcgi_buffer_size 64k;
  17.   fastcgi_buffers 4 64k;
  18.   fastcgi_busy_buffers_size 128k;
  19.   fastcgi_temp_file_write_size 256k;  gzip on;
  20.   gzip_min_length  1k;
  21.   gzip_buffers     4 16k;
  22.   gzip_http_version 1.0;
  23.   gzip_comp_level 2;
  24.   gzip_types       text/plain application/x-javascript text/css application/xml;
  25.   gzip_vary on;
  26.                 limit_zone  crawler  $binary_remote_addr  50m;
  27.   
  28.                 #log format
  29.   log_format  access  '$remote_addr - $remote_user [$time_local] "$request" '
  30.              '$status $body_bytes_sent "$http_referer" '
  31.              '"$http_user_agent" $http_x_forwarded_for';  include vhost/*.conf;
  32. }
复制代码

作者: longyushen    时间: 2012-11-5 14:31
顶上去看看
军哥怎么不说下
作者: licess    时间: 2012-11-5 15:56
https://bbs.vpser.net/thread-3017-1-1.html
作者: longyushen    时间: 2012-11-5 19:53
标题: 回复 6# 的帖子
可是文章中并没有提及到怎么限制速度,只是限制了并发数
作者: longyushen    时间: 2012-11-5 20:09
标题: 回复 6# 的帖子
安装提示在后面加了limit_conn oneip 20;提示这个
nginx: [emerg] zero size shared memory zone "oneip"
作者: licess    时间: 2012-11-5 20:13
标题: 回复 7# 的帖子
加个 limit_rate ××k;不就行了
作者: longyushen    时间: 2012-11-6 09:44
标题: 回复 9# 的帖子
不行,提示如下
Stoping LNMP...
Nginx program is stop
Shutting down php_fpm . done
PHP-FPM program is stop
MySQL program is not runing!
Starting LNMP...
nginx: [emerg] zero size shared memory zone "oneip"
Nginx start successfully!
Starting php_fpm  done
PHP-FPM start successfully!
Starting MySQL SUCCESS!
MySQL start successfully!
作者: longyushen    时间: 2012-11-6 09:47
标题: 回复 9# 的帖子
还是不行啊
这样的话会出错,但是不知道该怎么处理
作者: licess    时间: 2012-11-6 10:30
肯定是server段前没加上limit_zone  oneip  $binary_remote_addr  10m;
作者: longyushen    时间: 2012-11-6 13:32
已经搞定了




欢迎光临 VPS侦探论坛 (https://bbs.lnmp.com/) Powered by Discuz! X3.4