http {
include mime.types; #导入支持的文件类型
default_type application/octet-stream; #设置默认的类型,会提示下载不匹配的类型文件
#日志配置部分
#log_format main '$remote_addr -
r
e
m
o
t
e
−
u
s
e
r
[
remote-user [
remote−user[time_local] “KaTeX parse error: Expected 'EOF', got '#' at position 16: request" ' #̲ …status
b
o
d
y
b
y
t
e
s
s
e
n
t
"
body_bytes_sent "
bodybytessent"http_referer” ’
# ‘“
h
t
t
p
u
s
e
r
a
g
e
n
t
"
"
http_user_agent" "
httpuseragent""http_x_forwarded_for”’;
#access_log logs/access.log main;
#自定义优化参数
sendfile on; #实现文件零拷贝
#tcp_nopush on; #在开启了sendfile的情况下,合并请求后统一发送给客户端。
#tcp_nodelay off; #在开启了keepalived模式下的连接是否启用TCP_NODELAY选项,当为off的时候,延迟0.2发送,默认为on,不延迟发送,立即发送用户相应的报文。
#keepalive_timeout 0;
keepalive_timeout 65 65; #设置会话保持时间
#gzip on; 开启文件压缩
server {
listen 80; #设置监听的地址和端口
server_name localhost #设置server name,可以以空格隔开写多个并支持正则表达式,如*.magedu.com www.magedu.* www.(site\d+).magedu.com$ default_server
#charset koi8-r #设置编码格式,默认是俄语格式,可以改为utf-8
#access_log logs/host.access.log main;
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$ { #以http的方式转发php请求到指定web服务器
# proxy_pass http://127.0.0.1;
#}
# pass the PHP scripts to FastCGI server listening on 127.0.0.1:9000
#
#location ~ \.php$ { ##以fastcgi的方式转发php请求到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 { ##拒绝web形式访问执行文件,如很多的网站都是通过.htaccess文件来改变自己的重定向等功能
# deny all;
#}
}
# another virtual host using mix of IP-, name-, and port-based configuration
#
#server { ##自定义虚拟server
# listen 8000;
# listen somename:8080;
# server_name somename alias another.alias;
# location / {
# root html;
# index index.html index.htm; ##执行默认的网页文件,此指令由ngx_http_index_module模块提供
# }
#}
# HTTPS server
#
#server { ##https服务器配置
# 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;
# }
#}
}