##定义nginx运行的用户各用户组
user nginx nginx;javascript
##nginx进程数,建议设置与cpu核心数一致
worker_processes 1;php
##全局错误日志定义类型[ debug | info | notice | warn | error | crit ]css
##可使用多个error_log,每一个指向不一样的文件和不一样的日志记录,出了debug级别以外,error_log也能够取值: debug_core, debug_alloc, debug_mutex, debug_event, debug_http, debug_imaphtml
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;前端
##进程文件java
#pid logs/nginx.pid;node
##工做模式与链接数上限
events {nginx
##单个进程的最大链接数
worker_connections 65535;
}web
##设置http服务器
http {apache
##引入外置配置文件
include /etc/nginx/conf.d/*.conf;
##文件扩展名与文件类型映射表
include mime.types;
##默认文件类型
default_type application/octet-stream;
##默认编码
#charset utf-8;
##服务器名字的hash表大小
#server_name_hash_bucket_size 128;
##上传文件大小限制
#client_header_buffer_size 32K;
##设定请求缓存
#large_client_header_buffers 4 64K;
##最大缓存
client_max_body_size 8M;
##日志格式设定
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#log_format ldc ....;
##访问日志
#access_log logs/access.log main;
##开启高效文件传输模式sendfile指令指定nginx是否调用sendfile函数来输出文件,对于普通应用设为 on,若是用来进行下载等应用磁盘IO重负载应用,可设置为off,以平衡磁盘与网络I/O处理速度,下降系统的负载。注意:如 果图片显示不正常把这个改为off。
sendfile on;
##开启目录列表访问,合适下载服务器,默认关闭
#autoindex on;
##防止网络阻塞
#tcp_nopush on;
##防止网络阻塞
#tcp_nodelay on;
##长连接超时时间,单位是秒,为0,无超时
keepalive_timeout 65;
##gzip模块设置
##开启gzip压缩输出
#gzip on;
##最小压缩文件大小
#gzip_min_length 1k;
##压缩缓冲区
#gzip_buffers 4 16k;
##压缩版本(默认1.1,前端若是squid2.5请使用1.0)
#gzip_http_version 1.0;
##压缩等级
#gzip_comp_level 2;
##压缩类型,默认就已经包含了textxml,默认不用写,写上去也没有问题,会有一个warn
#gzip_types text/plain application/x-javascript text/css application/xml;
#gzip_vary on;
##开启链接限制ip链接数使用
#limit_zone crawler $binary_remote_addr 10m;
##FastCGI相关参数是为了改善网站的性能:减小资源占用,提升访问速度。
fastcgi_connect_timeout 300;
listen 80;
##域名能够有多个,用空格隔开
server_name localhost;
#server_id app1
#server_name app1
#charset koi8-r;
##定义本虚拟主机的访问日志
#access_log logs/host.access.log main;
#access_log logs/access.log ldc; 表示用ldc的log format
#include ssl/xxx.xx; 引入ssl证书
location / {
root html;
index index.html index.htm;
}
##图片缓存时间设置
location ~.*.(gif|jpg|jpeg|png|bmp|swf)${
expires 10d;
}
##js和CSS缓存时间设置
location ~.*.(js|css)?${
expires 1h;
}
#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;
#}
##设定查看Nginx状态的地址
##本地动静分离反向代理配置
}
}