nginx 配置react项目 并且开启gzip压缩

#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_comp_level 4;
    gzip_buffers 4 16k;
    gzip_min_length 1k;
    gzip_vary on;
    gzip_types *;
    

    server {
        listen       80;
        server_name  localhost;

        #charset koi8-r;

        #access_log  logs/host.access.log  main;

        location / {   #路径匹配是 /
       #映射到C:static/web root C:
/static/web;
#$uri 代表/login等域名后面的部分 这条语句是将/login这样的路由映射到index.html页面 try_files $uri
/
index.html; } } }

 

posted @ 2019-03-26 15:47  崔凯通  阅读(1128)  评论(0编辑  收藏  举报