前端优化之Nginx配置

该配置文件展示了如何使用Nginx优化前端大文件打包的代理传递,通过设置gzip压缩提高传输效率,针对不同路径配置多个proxy_pass以实现不同服务的负载均衡。同时,配置了禁用gzip的条件,以兼容不支持gzip的低版本浏览器。
摘要由CSDN通过智能技术生成

Nginx的一次优化前端打包过大的配置

#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  on;
 
server
	{   

	  listen 8899;
	  server_name 47.99.116.65,localhost;

    gzip on;
    gzip_buffers 32 4K;
    gzip_comp_level 6;
    gzip_min_length 100;
    gzip_types application/javascript text/css text/xml;
    gzip_disable "MSIE [1-6]\."; #配置禁用gzip条件,支持正则。此处表示ie6及以下不启用gzip(因为ie低版本不支持)
    gzip_vary on;

	  location /geoconv/ {
	   
	    proxy_pass http://api.map.baidu.com/geoconv/;
	  }
	  location /fives.web {
	   
	    proxy_pass http://localhost:8293/fives.web;
	  }
	  location /git {
	   
	    proxy_pass http://localhost:80/git;
	  }
	  location /5s.api {
	   
	    proxy_pass http://localhost:8293/5s.api;
	  }
	   location /flowrest {
	   
	    proxy_pass http://localhost:8294/flowrest;
	  }
	  location /fives.reports {
	   
	    proxy_pass http://localhost:8293/FiveS.Web/Fives.Reports;
	  }
	  location /mag/hls/ {
	   
	    proxy_pass http://qms.yiulian.com:8090/mag/hls/;
	    gzip_proxied off;
	  }	  
	  access_log logs/xxx456.tk_access.log;
	}
server
	{
	  listen 8891;
	  server_name 47.99.116.65,localhost;
	  location /fives.web/ {
	   
	    proxy_pass http://localhost:8193/fives.web/;
	  }	 
	  location /5s.api/ {
	   
	    proxy_pass http://localhost:8193/5s.api/;
	  }
	  location /fives.reports/ {
	   
	    proxy_pass http://localhost:8193/FiveS.Web/Fives.Reports/;
	  }
	   location /flowrest-demo/ {
	   
	    proxy_pass http://localhost:8294/flowrest-demo/;
	  }	  
	  
	  access_log logs/8891.tk_access.log;
	}
server
    {
      listen 8898;
      server_name 47.99.116.65;
      location /qms.welder {
       
        proxy_pass http://localhost:8092/;
      }
      location /Scripts {
        proxy_pass http://localhost:8092/scripts;
      }
       
      location /api/ {
        proxy_pass http://localhost:8092/api/;
      }
      
      location /Welder2/ {
        proxy_pass http://localhost:8092/Welder2/;
      }
     location /5s.api {
       
        proxy_pass http://localhost:8293/5s.api;
      }
      access_log logs/xxx456.tk_access.log;
    }
    # 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;
    #    }
    #}
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值