当前位置:首页 > nginx > 正文

nginx配置详解超详细(nginx配置文件详解超详细)

  • nginx
  • 2024-03-21 01:26:04
  • 7132
Nginx配置详解
工作进程
worker_processes:指定工作进程的数量。 例如:worker_processes 4;
事件
accept_mutex: 处理TCP连接的上锁模式。 默认值为"off",表示无锁。
use: 设置事件处理机制。 例如:use epoll;
日志
error_log: 设置错误日志的文件。 例如:error_log /var/log/nginx/error.log;
custom_log: 设置自定义日志。 例如:custom_log /var/log/nginx/access.log combined;
HTTP请求处理
server: 定义服务器块,监听端口和主机名。 例如:

server {
listen 80;
server_name example.com;
}

location: 定义一个处理请求的块。 例如:

location / {
root /var/www/html;
index index.html;
}

缓存
proxy_cache: 启用代理缓存。 例如:proxy_cache proxy;
proxy_cache_path: 设置缓存目录。 例如:proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=mycache:10m inactive=60m;
安全
ssl_certificate: 指定SSL证书路径。 例如:ssl_certificate /etc/ssl/nginx.crt;
ssl_protocols: 设置允许的SSL协议。 例如:ssl_protocols TLSv1 TLSv1.1 TLSv1.2;
其他设置
variables_hash_bucket_size: 设定变量哈希表的桶大小。 例如:variables_hash_bucket_size 128;
client_body_size: 允许的最大请求正文大小。 例如:client_body_size 100M;