nginx-tutorial/demos/nginx.conf

139 lines
3.8 KiB
Nginx Configuration File
Raw Normal View History

# ----------------------------------------------------
# 本文件是 nginx-1.14.0 的默认配置文件
# 我对一些重要参数加了中文注释
# ----------------------------------------------------
# 运行用户
#user nobody;
# 启动进程,通常设置成和 CPU 的数量相等
worker_processes 1;
# 全局错误日志
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
# PID 文件,记录当前启动的 nginx 的进程 ID
#pid logs/nginx.pid;
# 工作模式及连接数上限
events {
worker_connections 1024; #单个后台 worker process 进程的最大并发链接数
}
# 设定 http 服务器,利用它的反向代理功能提供负载均衡支持
http {
# 设定 mime 类型(邮件支持类型),类型由 mime.types 文件定义
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"';
#access_log logs/access.log main;
# sendfile 指令指定 nginx 是否调用 sendfile 函数zero copy 方式)来输出文件,对于普通应用,
# 必须设为 on,如果用来进行下载等应用磁盘 IO 重负载应用,可设置为 off以平衡磁盘与网络 I/O 处理速度,降低系统的 uptime。
sendfile on;
#tcp_nopush on;
# 连接超时时间
#keepalive_timeout 0;
keepalive_timeout 65;
# gzip 压缩开关
#gzip on;
# 设定实际的服务器列表
server {
# 监听 80 端口80 端口是知名端口号用于HTTP协议
listen 80;
# 定义使用的访问域名host
server_name localhost;
# 编码格式
#charset utf-8;
#access_log logs/host.access.log main;
# 反向代理的路径(和 upstream 绑定location 后面设置映射的路径
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;
# }
#}
}