#user nobody;
worker_processes auto;
#error_log logs/error.log;
error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
worker_rlimit_nofile 100000;
events {
use epoll;
worker_connections 204800;
}
http {
## 用户的IP 地址$binary_remote_addr 作为Key,每个IP 地址最多有50 个并发连接
## 你想开几千个连接刷死我?超过50 个连接,直接返回503 错误给你,根本不处理你的请求了
limit_conn_zone $binary_remote_addr zone=TotalConnLimitZone:10m ;
#limit_conn TotalConnLimitZone 50;
limit_conn TotalConnLimitZone 500;
limit_conn_log_level notice;
## 用户的IP 地址$binary_remote_addr 作为Key,每个IP 地址每分钟处理50 个请求## 你想用程序每秒几百次的刷我,没戏,再快了就不处理了,直接返回503 错误给你
#limit_req_zone $binary_remote_addr zone=ConnLimitZone:10m rate=200r/m;
limit_req_zone $binary_remote_addr zone=ConnLimitZone:10m rate=2000r/m;
limit_req_log_level notice;
#include mime.types;
#default_type application/octet-stream;
#access_log logs/access.log main;
#server_tokens off;
#sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
#keepalive_timeout 65;
server_tokens off;
include mime.types;
default_type application/octet-stream;
log_format main '$remote_addr - $remote_user [$time_local] $request '
'"$status" $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for" "$gzip_ratio"';access_log off;
charset utf-8;
server_names_hash_bucket_size 128;
client_body_buffer_size 2k;
client_header_buffer_size 2k;
large_client_header_buffers 4 4k;
client_max_body_size 8m;
client_body_timeout 10;
client_header_timeout 10;
send_timeout 10;
#limit_zone slimits $binary_remote_addr 5m;
#limit_conn slimits 5;
sendfile on;
tcp_nopush on;
keepalive_timeout 15;
fastcgi_cache_path /home/fastcgi_cache levels=1:2
keys_zone=TEST:10m
inactive=1d
max_size=3000m;
fastcgi_connect_timeout 300;
fastcgi_send_timeout 300;
fastcgi_read_timeout 300;
fastcgi_buffer_size 4k;
fastcgi_buffers 8 4k;
fastcgi_busy_buffers_size 8k;
fastcgi_temp_file_write_size 8k;
#fastcgi_cache yunong;
fastcgi_cache_valid 200 302 1h;
fastcgi_cache_valid 301 1d;
fastcgi_cache_valid any 1m;
fastcgi_cache_min_uses 1;
fastcgi_cache_use_stale error timeout invalid_header http_500;
open_file_cache max=204800 inactive=20s;
open_file_cache_min_uses 1;
open_file_cache_valid 30s;
tcp_nodelay on;
gzip on;
gzip_min_length 1k;
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;
include /usr/local/nginx/conf.d/*.conf;
# server {
# listen 80;
# server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
# location / {
# root html;
# index index.html index.htm;
# }
#error_page 404 /404.html;
# redirect server error pages to the static page /50x.html
#
#error_page 500 502 503 504 /50x.html;
#location = /50x.html {
# root html;
#}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ {
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ {
# root html;
# fastcgi_pass 127.0.0.1:9000;
# fastcgi_index index.php;
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name;
# include fastcgi_params;
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht {
# deny all;
#}
#}
# another virtual host using mix of IP-, name-, and port-based configuration #
#server {
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm;
# }
#}
# HTTPS server
#
#server {
# listen 443 ssl;
# server_name localhost;
# ssl_certificate cert.pem;
# ssl_certificate_key cert.key;
# ssl_session_cache shared:SSL:1m;
# ssl_session_timeout 5m;
# ssl_ciphers HIGH:!aNULL:!MD5;
# ssl_prefer_server_ciphers on;
# location / {
# root html;
# index index.html index.htm;
# }
#}
}。