longyushen 发表于 2012-11-2 12:49:40

nginx无法实现模块限制速度并发数

nginx无法实现模块限制速度并发数出现如下错误nginx: unknown directive "log_format" in /usr/local/nginx/conf/nginx.conf:62nginx配置如下userwww www;worker_processes 1;error_log/home/wwwlogs/nginx_error.logcrit;pid      /usr/local/nginx/logs/nginx.pid;#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;events
{
use epoll;
worker_connections 51200;
}http
{
include       mime.types;
default_typeapplication/octet-stream;server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;sendfile on;
tcp_nopush   on;keepalive_timeout 60;tcp_nodelay on;fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;gzip on;
gzip_min_length1k;
gzip_buffers   4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types       text/plain application/x-javascript text/css application/xml;
gzip_vary on;# limit_zone   one$binary_remote_addr10m;
server {
    location /www/ {
      limit_conn   one2;
      limit_rate 300k;
    }
}
}   #log format
log_formataccess'$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';include vhost/*.conf;
}

skyfree 发表于 2012-11-3 07:53:55

# limit_zone   one$binary_remote_addr10m;

把#去掉好吧……?

licess 发表于 2012-11-3 16:53:27

我只能说配置文件已经让你该的面目全非了

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

longyushen 发表于 2012-11-5 09:24:44

原帖由 licess 于 2012-11-3 16:53 发表 https://bbs.vpser.net/images/common/back.gif
我只能说配置文件已经让你该的面目全非了

只按错误提示log_format放错地方了,要在server前面
对于下面的源码,该怎么写呢?

userwww www;worker_processes 1;error_log/home/wwwlogs/nginx_error.logcrit;pid      /usr/local/nginx/logs/nginx.pid;#Specifies the value for maximum file descriptors that can be opened by this process.
worker_rlimit_nofile 51200;events
{
use epoll;
worker_connections 51200;
}http
{
include       mime.types;
default_typeapplication/octet-stream;server_names_hash_bucket_size 128;
client_header_buffer_size 32k;
large_client_header_buffers 4 32k;
client_max_body_size 50m;sendfile on;
tcp_nopush   on;keepalive_timeout 60;tcp_nodelay on;fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 64k;
fastcgi_buffers 4 64k;
fastcgi_busy_buffers_size 128k;
fastcgi_temp_file_write_size 256k;gzip on;
gzip_min_length1k;
gzip_buffers   4 16k;
gzip_http_version 1.0;
gzip_comp_level 2;
gzip_types       text/plain application/x-javascript text/css application/xml;
gzip_vary on;
                limit_zonecrawler$binary_remote_addr50m;

                #log format
log_formataccess'$remote_addr - $remote_user [$time_local] "$request" '
             '$status $body_bytes_sent "$http_referer" '
             '"$http_user_agent" $http_x_forwarded_for';include vhost/*.conf;
}

longyushen 发表于 2012-11-5 14:31:54

顶上去看看
:handshake 军哥怎么不说下

licess 发表于 2012-11-5 15:56:51

https://bbs.vpser.net/thread-3017-1-1.html

longyushen 发表于 2012-11-5 19:53:37

回复 6# 的帖子

可是文章中并没有提及到怎么限制速度,只是限制了并发数

longyushen 发表于 2012-11-5 20:09:55

回复 6# 的帖子

安装提示在后面加了limit_conn oneip 20;提示这个
nginx: zero size shared memory zone "oneip"

licess 发表于 2012-11-5 20:13:05

回复 7# 的帖子

加个 limit_rate ××k;不就行了

longyushen 发表于 2012-11-6 09:44:35

回复 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: zero size shared memory zone "oneip"
Nginx start successfully!
Starting php_fpmdone
PHP-FPM start successfully!
Starting MySQL SUCCESS!
MySQL start successfully!

longyushen 发表于 2012-11-6 09:47:38

回复 9# 的帖子

还是不行啊
这样的话会出错,但是不知道该怎么处理

licess 发表于 2012-11-6 10:30:43

肯定是server段前没加上limit_zoneoneip$binary_remote_addr10m;

longyushen 发表于 2012-11-6 13:32:03

:lol :victory: :handshake 已经搞定了
页: [1]
查看完整版本: nginx无法实现模块限制速度并发数