nginx 限制并发

worker_processes  1;

#error_log  logs/error.log;
#error_log  logs/error.log  notice;
#error_log  logs/error.log  info;

events {
    worker_connections  1024;
}

# http conf
http {
    #include     http/common.conf;
    #include     http/cache.conf;
    #include     http/resty.conf;
    #include     http/mime.types;

    include     http/*.conf;

    include     http/servers/*.conf;
    log_format  main  '[$HOST] -[$realip_remote_addr]- $remote_addr - $remote_user [$time_local] "$request" '
                      '$status $body_bytes_sent "$http_referer" '
                      '"$http_user_agent" "$http_x_forwarded_for" "$request_filename"';
     gzip on;
     gzip_min_length 1000;
     gzip_buffers 4 8k;
     gzip_types text/plain application/x-javascript text/css application/json application/xml text/javascript;
     access_log  logs/access.log  main;  
     limit_conn_zone $binary_remote_addr zone=addr:10m;
        #charset koi8-r;

        #access_log  logs/host.access.log  main;
server{
        listen      2443;
        server_name 192.168.137.3;
        #port_in_redirect off;
        #ssl on;
        #从腾讯云获取到的第一个文件的全路径
        ssl_certificate /etc/ssl/server.pem;
        ssl_certificate_key /etc/ssl/server.key;
   
        location / {
           limit_conn_status 500;
           limit_conn_log_level warn;
           limit_rate 50;
           limit_conn addr 1;
           alias /var/www/html/;
        }
    }
}


Last login: Mon Jun 21 10:41:44 2021 from 192.168.137.1
node1:/root#curl 127.0.0.1:2443
<html>
<head><title>500 Internal Server Error</title></head>
<body>
<center><h1>500 Internal Server Error</h1></center>
<hr><center>nginx/1.17.9</center>
</body>
</html>