#user nobody;
worker_processes 12; #要与CPU核心数一致
worker_rlimit_nofile 65535; #调整到最大
events {
worker_connections 65535; #调整到最大
}
http {
include mime.types;
default_type application/octet-stream;
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 128k;
sendfile on;
underscores_in_headers on;
keepalive_timeout 65;
proxy_connect_timeout 2;
proxy_send_timeout 300;
proxy_read_timeout 300;
proxy_buffer_size 1M;
proxy_buffers 8 1M;
proxy_busy_buffers_size 1M;
proxy_temp_file_write_size 1M;
#负载均衡举例
upstream ymyy-i-test
{
server localhost:21027;
server localhost:21028;
}
#负载均衡举例
server {
listen 80;
server_name localhost;
#访问日志 按网站,按时间分割
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})")
{
set $year $1;
set $month $2;
set $day $3;
set $hour $4;
set $minutes $5;
set $seconds $6;
}
#访问日志 按网站,按时间分割
access_log logs/ymyy-t-access-$year$month$day.log;
#错误日志 按网站分割
error_log logs/ymyy-t-error.log;
location / {
proxy_pass http://ymyy-i-test;
}
}
#接口HTTPS举例
server {
#SSL 访问端口号为 443
listen 443 ssl;
#填写绑定证书的域名
server_name abc.com;
#证书文件名称
ssl_certificate 1_gdmk.cn_bundle.crt;
#私钥文件名称
ssl_certificate_key 2_gdmk.cn.key;
ssl_session_timeout 5m;
#请按照以下协议配置
ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
#请按照以下套件配置,配置加密套件,写法遵循 openssl 标准。
ssl_ciphers ECDHE-RSA-AES128-GCM-SHA256:HIGH:!aNULL:!MD5:!RC4:!DHE;
ssl_prefer_server_ciphers on;
underscores_in_headers on;
if ($time_iso8601 ~ "^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})")
{
set $year $1;
set $month $2;
set $day $3;
set $hour $4;
set $minutes $5;
set $seconds $6;
}
#访问日志 按网站,按时间分割
access_log logs/ymyy-i-access-$year$month$day.log;
#错误日志 按网站分割
error_log logs/ymyy-i-error.log;
location / {
proxy_pass http://localhost:21020;
}
}
}
如果在windows下使用nginx要使用Windows专用版本,否则高并发时有限制。