nginx.conf基本配置
#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
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 on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#开启静态资源gzip压缩
gzip on;
#gzip_min_length 1024k;
#当返回内容大于此值时才会使用gzip进行压缩,以K为单位,当值为0时,所有页面都进行压缩。
gzip_min_length 10k;
gzip_buffers 4 16k;
#设置gzip压缩级别,级别越底压缩速度越快文件压缩比越小,反之速度越慢文件压缩比越大
gzip_comp_level 3;
#gzip 为on时需要配置 gzip_types才能生效
gzip_types text/html text/xml text/javascript application/javascript text/css text/plain text/json application/json;
# server 配置将请求分发至哪个环境
upstream web {
server localhost:8080;
#server 127.0.0.1:8080/ICP1.0;
}
server {
listen 80; #监听的端口
server_name localhost;
#设置允许附件上传的大小
client_max_body_size 10M;
#附件存放位置
location /fileServer{
alias C:/S;
}
location /JSON_FILE{
alias C:/S/userData/;
add_header Access-Control-Allow-Origin *;
add_header Access-Control-Allow-Methods GET,POST,PUT,DELETE,OPTIONS;
default_type "application/json";
add_header Cache-Control no-cache;
add_header Pragma no-cache;
add_header Expires 0;
}
#后台服务地址
location /icp{
proxy_pass http://web;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_read_timeout 3600;
client_max_body_size 10m;
}
#静态页面
location /Vue-ICP1.0{
root F://netinfo@20190902
etinfo-product-icpVue-ICP1.0;
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
以上是 nginx.conf基本配置 的全部内容, 来源链接: utcz.com/z/517292.html