原文:https://www.johnrosen1.com/nginx1/
Nginx作为一款开源,高性能,高并发,配置简单的网站服务器(Web Server),被相当多网站所采用,本文介绍Linux下Nginx的简单效能与安全优化方法。
NGINX Docs | Welcome to NGINX documentation
Welcome to NGINX documentation. NGINX is a free, open-source, high-performance HTTP server, reverse proxy, and IMAP/POP3 proxy server.

Nginx主配置nginx.conf
user nginx;
worker_processes auto; #worker数量必须和CPU核心数量一样,选择auto可以自动设置
error_log /var/log/nginx/error.log warn;
pid /var/run/nginx.pid;
include /etc/nginx/modules-enabled/*.conf;
events {
worker_connections 3000; #决定每个Worker进程可以服务多少客户
use epoll; #使用异步架构,一个线程可以服务许多客户
multi_accept on; #同时接受尽可能多的连接
}
http {
aio threads; #使用异步i/o,避免因为i/o问题导致Nginx阻塞
charset UTF-8; #使用UTF-8避免中文乱码问题
tcp_nodelay on; #不要缓存数据,尽可能快速发送
tcp_nopush on; #将http headers一起发送,而非一个个分开发送
server_tokens off; #不发送Nginx版本号,提高安全性
include /etc/nginx/mime.types;
default_type application/octet-stream;
access_log /var/log/nginx/access.log;
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
'$status $body_bytes_sent "$http_referer" '
'"$http_user_agent" "$http_x_forwarded_for"';
sendfile on; #支持將數據從一個地方直接複製到另一個地方
gzip on; #使用gzip压缩降低带宽占用
include /etc/nginx/conf.d/*.conf;
}
Nginx Server配置优化