include mime.types; #引用服务器可以支持的文件类型
default_type application/octet-stream; #配置处理前端请求的MIME类型,#指定默认类型为二进制流,也就是当文件类型未 定义时使用这种方式,例如在没有配置PHP环境时,Nginx是不予解析的,此时,用浏览器访问PHP文件就会出现下载窗口
#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 on; #文件高效传输
#tcp_nopush on; ## tcp_nopush,tcp_nodelay设置on,防止网络阻塞
#keepalive_timeout 0;
client_header_timeout 10;#指定客户端请求头读取超时时间,如果超过这个时间,客户 端还没有发送任何数据,Nginx将返回“Request time out(408)”错误
keepalive_timeout 65; #指定客户端连接保持活动的超时时间
#gzip on; ##开启gzip压缩,实时压缩输出数据流
server { #server 模块 虚拟主机
listen 80; #监听端口
server_name localhost; #请求的域名或者IP
#charset koi8-r; #指定Nginx默认的字符集,只有utf-8支持中文字符
#access_log logs/host.access.log main;#指定日志访问的格式和位置
location / { #捕获/的请求 相当于server的指令
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 { 捕获/50x的请求
root html;
}
# proxy the PHP scripts to Apache listening on 127.0.0.1:80
#
#location ~ \.php$ { #匹配以PHP结尾的URL
# proxy_pass http://127.0.0.1; #将请求发送给这个IP
#}
# 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接口将请求发送给这个IP
# fastcgi_index index.php; #设置首页
# fastcgi_param SCRIPT_FILENAME /scripts$fastcgi_script_name; # 在浏览器中访问的.php文件,实际读取的是 $document_root(网站根目录)下的.php文件
# include fastcgi_params; #引用这个文件
#}
# deny access to .htaccess files, if Apache's document root
# concurs with nginx's one
#
#location ~ /\.ht { #以~ /\.ht为结尾的URL 全部拒绝访问
# 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;
# }
#}
}
转载于:https://blog.51cto.com/1362336072/2061415